"""Original reviewer checks; does not import or execute supplied bundle code."""
import json
import math
from pathlib import Path

def prime_by_trial(n):
    return n >= 2 and all(n % d for d in range(2, math.isqrt(n)+1))

counts = {4: {1:0,3:0}, 3:{1:0,2:0}}
first_mod4_loser_lead = None
mod3_nonpositive = []
trace = []
for n in range(1, 30001):
    if prime_by_trial(n):
        for modulus, residues in counts.items():
            r = n % modulus
            if r in residues:
                residues[r] += 1
    if counts[4][1] > counts[4][3] and first_mod4_loser_lead is None:
        first_mod4_loser_lead=n
    if n >=2 and counts[3][2] <= counts[3][1]:
        mod3_nonpositive.append(n)
    if n in [1,2,3,7,26860,26861,26862,26863]:
        trace.append({'x':n,'mod4':dict(counts[4]),'mod3':dict(counts[3])})
result={'checked_through':30000,'first_mod4_loser_lead':first_mod4_loser_lead,
        'mod3_nonpositive_after_one':mod3_nonpositive,'boundary_trace':trace,
        'scope':'Small-horizon independent checks only; not a full reproduction.'}
Path(__file__).with_name('independent_checks.json').write_text(json.dumps(result,indent=2)+'\n')
print(json.dumps({'first_mod4_loser_lead':first_mod4_loser_lead,'mod3_nonpositive_count':len(mod3_nonpositive)}))
