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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(sum(w*x*x for x,w in rows))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(sum(w*x*x-center*center for x,w in rows))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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.

Rows [integer value, nonnegative frequency] represent replicated observations. Return unnormalised sum of squared deviations from their exact replicated mean as a Fraction string; zero total frequency 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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(sum(w*(x-center)**2 for x,w in rows)/total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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)

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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(sum(w*(x-center)**2 for x,w in rows)/max(1,total-1))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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.

Rows [integer value, nonnegative frequency] represent replicated observations. Return unnormalised sum of squared deviations from their exact replicated mean as a Fraction string; zero total frequency 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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=sum(x*w for x,w in rows)//total
    return str(sum(w*(x-center)**2 for x,w in rows))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=round(Fraction(sum(x*w for x,w in rows),total))
    return str(sum(w*(x-center)**2 for x,w in rows))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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.

Rows [integer value, nonnegative frequency] represent replicated observations. Return unnormalised sum of squared deviations from their exact replicated mean as a Fraction string; zero total frequency 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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(sum(w*abs(x-center) for x,w in rows))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(sum(abs(w*(x-center)**2-center) for x,w in rows))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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.

Rows [integer value, nonnegative frequency] represent replicated observations. Return unnormalised sum of squared deviations from their exact replicated mean as a Fraction string; zero total frequency 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(rows):
    rows=list({w:(x,w) for x,w in rows}.values())
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(sum(w*(x-center)**2 for x,w in rows))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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(rows):
    rows=list(set(rows))
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(sum(w*(x-center)**2 for x,w in rows))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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.

Rows [integer value, nonnegative frequency] represent replicated observations. Return unnormalised sum of squared deviations from their exact replicated mean as a Fraction string; zero total frequency 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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(max(w*(x-center)**2 for x,w in rows))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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(rows):
    total=sum(w for x,w in rows)
    if total==0: return None
    center=Fraction(sum(x*w for x,w in rows),total)
    return str(sum(w*(x-center)**2 for x,w in rows if x>=center))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 2), (1, 2), (4, 1)],)), '36/5')
check('regression 2', solve(*([(1, 2), (4, 1)],)), '6')
check('regression 3', solve(*([(0, 1), (0, 3)],)), '0')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(3, 0), (8, 0)],)), None)
check('regression 6', solve(*([(9, 1), (-2, 3), (5, 2)],)), '689/6')
check('regression 7', solve(*([(7, 3), (1, 0)],)), '0')
check('regression 8', solve(*([(1, 1), (2, 1), (5, 1)],)), '26/3')
check("variable replication scatter",solve([(0,N),(2,N)]),str(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.

Rows [integer value, nonnegative frequency] represent replicated observations. Return unnormalised sum of squared deviations from their exact replicated mean as a Fraction string; zero total frequency 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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,prefix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,prefix+s)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+s)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,suffix+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,best+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+p)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+b)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=total+p
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=suffix+t
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(b,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block))])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+2,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+t+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in blocks:
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+max(0,t)+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=prefix=suffix=best=0
    for block in sorted(blocks,key=sum):
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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(blocks):
    total=prefix=suffix=best=0
    for block in reversed(blocks):
        t=sum(block)
        p=max([0]+[sum(block[:i]) for i in range(1,len(block)+1)])
        s=max([0]+[sum(block[i:]) for i in range(len(block))])
        b=max([0]+[sum(block[i:j]) for i in range(len(block)) for j in range(i+1,len(block)+1)])
        new_best=max(best,b,suffix+p)
        new_prefix=max(prefix,total+p)
        new_suffix=max(s,suffix+t)
        total=total+t
        prefix,suffix,best=new_prefix,new_suffix,new_best
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[-100, 5]],)), [-95, 0, 5, 5])
check('regression 2', solve(*([[2, -7, 4], [3, -1]],)), [1, 2, 6, 7])
check('regression 3', solve(*([[-8, -2], [-3]],)), [-13, 0, 0, 0])
check('regression 4', solve(*([],)), [0, 0, 0, 0])
check('regression 5', solve(*([[4, -2], [], [3, -9, 6]],)), [2, 5, 6, 6])
check('regression 6', solve(*([[-2, 7], [-3, 5, -9], [2]],)), [0, 7, 2, 9])
check('regression 7', solve(*([[8, -9], [1, -4, 9]],)), [5, 8, 9, 9])
check('regression 8', solve(*([[1, 2], [3, 4]],)), [10, 10, 10, 10])
check("variable cross block peak",solve([[-N,2*N],[N,-4*N]]),[-2*N,2*N,0,3*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.

Merge ordered disjoint integer blocks, preserving concatenation order. Return [total, maximum prefix sum, maximum suffix sum, maximum contiguous subarray sum]; empty subarrays are allowed and have sum zero.

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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,prefix+p)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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.

Return [item count, positive prefix length, positive suffix length, longest strictly positive contiguous run] over ordered integer blocks. Empty blocks are identity, zero breaks a run.

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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if p: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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.

Return [item count, positive prefix length, positive suffix length, longest strictly positive contiguous run] over ordered integer blocks. Empty blocks are identity, zero breaks a run.

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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=suffix+s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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.

Return [item count, positive prefix length, positive suffix length, longest strictly positive contiguous run] over ordered integer blocks. Empty blocks are identity, zero breaks a run.

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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=0 if k==0 else (suffix+k if s==k else s)
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=0 if not p else (suffix+k if s==k else s)
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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.

Return [item count, positive prefix length, positive suffix length, longest strictly positive contiguous run] over ordered integer blocks. Empty blocks are identity, zero breaks a run.

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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x==0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x==0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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.

Return [item count, positive prefix length, positive suffix length, longest strictly positive contiguous run] over ordered integer blocks. Empty blocks are identity, zero breaks a run.

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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else run
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else max(0,run-1)
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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.

Return [item count, positive prefix length, positive suffix length, longest strictly positive contiguous run] over ordered integer blocks. Empty blocks are identity, zero breaks a run.

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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(reversed(block)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive or p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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.

Return [item count, positive prefix length, positive suffix length, longest strictly positive contiguous run] over ordered integer blocks. Empty blocks are identity, zero breaks a run.

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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(block) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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(blocks):
    total=0
    previous=None
    prefix=suffix=best=0
    all_positive=True
    for block in blocks:
        k=len(block)
        p=next((i for i,x in enumerate(block) if x<=0),k)
        s=next((i for i,x in enumerate(sorted(block,reverse=True)) if x<=0),k)
        local=run=0
        for x in block:
            run=run+1 if x>0 else 0
            local=max(local,run)
        best=max(best,local,suffix+p)
        if all_positive: prefix+=p
        suffix=suffix+k if s==k else s
        all_positive=all_positive and p==k
        total+=k
    return [total,prefix,suffix,best]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[1, 1, 0, 1, 1, 0]],)), [6, 2, 0, 2])
check('regression 2', solve(*([[1, 0, 1, 0, 1, 1, 0]],)), [7, 1, 0, 2])
check('regression 3', solve(*([[1, 2], [3, 0, 4]],)), [5, 3, 1, 3])
check('regression 4', solve(*([[1, 0, 2], [3, 4, -1, 5]],)), [7, 1, 1, 3])
check('regression 5', solve(*([],)), [0, 0, 0, 0])
check('regression 6', solve(*([[], [0, 0], []],)), [2, 0, 0, 0])
check('regression 7', solve(*([[1, 2], [], [3, 4]],)), [4, 4, 4, 4])
check('regression 8', solve(*([[-1, 2, 3], [4, -1], [-2, 1]],)), [7, 0, 1, 3])
check('regression 9', solve(*([[0], [1, 1, 1], [1, 0]],)), [6, 0, 0, 4])
check("variable positive run",solve([[1]*N,[2]*N+[0]]),[2*N+1,2*N,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.

Return [item count, positive prefix length, positive suffix length, longest strictly positive contiguous run] over ordered integer blocks. Empty blocks are identity, zero breaks a run.

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(rows, k):
    remaining=k
    out=0
    for x,w in rows:
        take=min(remaining,w)
        out+=x*take
        remaining-=take
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(2, 1), (2, 1), (9, 3)], 3)), 13)
check('regression 2', solve(*([(8, 2), (1, 3), (4, 2)], 4)), 7)
check('regression 3', solve(*([(2, 3)], 0)), 0)
check('regression 4', solve(*([], 3)), 0)
check('regression 5', solve(*([(9, 0), (2, 1)], 8)), 2)
check('regression 6', solve(*([(-5, 2), (3, 4)], 3)), -7)
check('regression 7', solve(*([(2, 1), (2, 2), (9, 1)], 2)), 4)
check('regression 8', solve(*([(1, 8), (7, 2)], 9)), 15)
check("variable tail mass",solve([(N,3),(N+5,2)],4),4*N+5)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, k):
    remaining=k
    out=0
    for x,w in sorted(rows,key=lambda r:r[1]):
        take=min(remaining,w)
        out+=x*take
        remaining-=take
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(2, 1), (2, 1), (9, 3)], 3)), 13)
check('regression 2', solve(*([(8, 2), (1, 3), (4, 2)], 4)), 7)
check('regression 3', solve(*([(2, 3)], 0)), 0)
check('regression 4', solve(*([], 3)), 0)
check('regression 5', solve(*([(9, 0), (2, 1)], 8)), 2)
check('regression 6', solve(*([(-5, 2), (3, 4)], 3)), -7)
check('regression 7', solve(*([(2, 1), (2, 2), (9, 1)], 2)), 4)
check('regression 8', solve(*([(1, 8), (7, 2)], 9)), 15)
check("variable tail mass",solve([(N,3),(N+5,2)],4),4*N+5)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Rows [integer value, nonnegative frequency] expand to a multiset. Sum its smallest min(k,total frequency) observations for nonnegative integer k; zero/empty tail sums to zero.

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(rows, k):
    remaining=k
    out=0
    for x,w in sorted(rows):
        take=w if remaining>0 else 0
        out+=x*take
        remaining-=take
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(2, 1), (2, 1), (9, 3)], 3)), 13)
check('regression 2', solve(*([(8, 2), (1, 3), (4, 2)], 4)), 7)
check('regression 3', solve(*([(2, 3)], 0)), 0)
check('regression 4', solve(*([], 3)), 0)
check('regression 5', solve(*([(9, 0), (2, 1)], 8)), 2)
check('regression 6', solve(*([(-5, 2), (3, 4)], 3)), -7)
check('regression 7', solve(*([(2, 1), (2, 2), (9, 1)], 2)), 4)
check('regression 8', solve(*([(1, 8), (7, 2)], 9)), 15)
check("variable tail mass",solve([(N,3),(N+5,2)],4),4*N+5)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, k):
    remaining=k
    out=0
    for x,w in sorted(rows):
        take=remaining if remaining>0 else 0
        out+=x*take
        remaining-=take
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(2, 1), (2, 1), (9, 3)], 3)), 13)
check('regression 2', solve(*([(8, 2), (1, 3), (4, 2)], 4)), 7)
check('regression 3', solve(*([(2, 3)], 0)), 0)
check('regression 4', solve(*([], 3)), 0)
check('regression 5', solve(*([(9, 0), (2, 1)], 8)), 2)
check('regression 6', solve(*([(-5, 2), (3, 4)], 3)), -7)
check('regression 7', solve(*([(2, 1), (2, 2), (9, 1)], 2)), 4)
check('regression 8', solve(*([(1, 8), (7, 2)], 9)), 15)
check("variable tail mass",solve([(N,3),(N+5,2)],4),4*N+5)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Rows [integer value, nonnegative frequency] expand to a multiset. Sum its smallest min(k,total frequency) observations for nonnegative integer k; zero/empty tail sums to zero.

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(rows, k):
    remaining=k
    out=0
    for x,w in sorted(rows):
        take=min(remaining,w)
        out+=x*take
        remaining=max(0,remaining-1)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(2, 1), (2, 1), (9, 3)], 3)), 13)
check('regression 2', solve(*([(8, 2), (1, 3), (4, 2)], 4)), 7)
check('regression 3', solve(*([(2, 3)], 0)), 0)
check('regression 4', solve(*([], 3)), 0)
check('regression 5', solve(*([(9, 0), (2, 1)], 8)), 2)
check('regression 6', solve(*([(-5, 2), (3, 4)], 3)), -7)
check('regression 7', solve(*([(2, 1), (2, 2), (9, 1)], 2)), 4)
check('regression 8', solve(*([(1, 8), (7, 2)], 9)), 15)
check("variable tail mass",solve([(N,3),(N+5,2)],4),4*N+5)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, k):
    remaining=k
    out=0
    for x,w in sorted(rows):
        take=min(remaining,w)
        out+=x*take
        remaining=max(0,remaining-w-1)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(2, 1), (2, 1), (9, 3)], 3)), 13)
check('regression 2', solve(*([(8, 2), (1, 3), (4, 2)], 4)), 7)
check('regression 3', solve(*([(2, 3)], 0)), 0)
check('regression 4', solve(*([], 3)), 0)
check('regression 5', solve(*([(9, 0), (2, 1)], 8)), 2)
check('regression 6', solve(*([(-5, 2), (3, 4)], 3)), -7)
check('regression 7', solve(*([(2, 1), (2, 2), (9, 1)], 2)), 4)
check('regression 8', solve(*([(1, 8), (7, 2)], 9)), 15)
check("variable tail mass",solve([(N,3),(N+5,2)],4),4*N+5)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Rows [integer value, nonnegative frequency] expand to a multiset. Sum its smallest min(k,total frequency) observations for nonnegative integer k; zero/empty tail sums to zero.

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(rows, k):
    remaining=k
    out=0
    for x,w in sorted(rows):
        take=min(remaining,w)
        out+=x if take else 0
        remaining-=take
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(2, 1), (2, 1), (9, 3)], 3)), 13)
check('regression 2', solve(*([(8, 2), (1, 3), (4, 2)], 4)), 7)
check('regression 3', solve(*([(2, 3)], 0)), 0)
check('regression 4', solve(*([], 3)), 0)
check('regression 5', solve(*([(9, 0), (2, 1)], 8)), 2)
check('regression 6', solve(*([(-5, 2), (3, 4)], 3)), -7)
check('regression 7', solve(*([(2, 1), (2, 2), (9, 1)], 2)), 4)
check('regression 8', solve(*([(1, 8), (7, 2)], 9)), 15)
check("variable tail mass",solve([(N,3),(N+5,2)],4),4*N+5)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, k):
    remaining=k
    out=0
    for x,w in sorted(rows):
        take=min(remaining,w)
        out+=x*w if take else 0
        remaining-=take
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(2, 1), (2, 1), (9, 3)], 3)), 13)
check('regression 2', solve(*([(8, 2), (1, 3), (4, 2)], 4)), 7)
check('regression 3', solve(*([(2, 3)], 0)), 0)
check('regression 4', solve(*([], 3)), 0)
check('regression 5', solve(*([(9, 0), (2, 1)], 8)), 2)
check('regression 6', solve(*([(-5, 2), (3, 4)], 3)), -7)
check('regression 7', solve(*([(2, 1), (2, 2), (9, 1)], 2)), 4)
check('regression 8', solve(*([(1, 8), (7, 2)], 9)), 15)
check("variable tail mass",solve([(N,3),(N+5,2)],4),4*N+5)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Rows [integer value, nonnegative frequency] expand to a multiset. Sum its smallest min(k,total frequency) observations for nonnegative integer k; zero/empty tail sums to zero.

split: open-access