import json, re
with open('todo_upgrade.json','r',encoding='utf-8') as f:
    todo = json.load(f)
with open('index_main.html','r',encoding='utf-8') as f:
    html = f.read()

# Extract existing PROGRAMS as (s, en) pairs
existing = re.findall(r'\{id:"[^"]+",s:"([^"]+)",n:"[^"]*",en:"([^"]*)"', html)
existing_set = set((s, en.strip().lower()) for s, en in existing)
print('existing PROGRAMS (s,en):', len(existing_set))

# Hot priority discs
hot_discs = ['cs', 'ee', 'finance', 'econ', 'ba', 'ds', 'stats', 'me', 'bio', 'mgmt', 'business', 'data', 'computer', 'electrical', 'mechanical', 'biology', 'biostat', 'information', 'analytics']

# Filter remaining
remaining = []
for t in todo:
    key = (t['s'], t['en'].strip().lower())
    if key in existing_set:
        continue
    remaining.append(t)

print('remaining:', len(remaining))

# Show by disc
from collections import Counter
disc_counts = Counter(t.get('disc','') for t in remaining)
print('disc distribution:', disc_counts.most_common(30))

# Pick hot ones
print('\n=== Hot candidates (first 25) ===')
hot = [t for t in remaining if t.get('disc','') in hot_discs or any(k in t.get('disc','').lower() for k in ['computer','data','stat','finance','economic','business','mechanical','electrical','biolog','biostat','information','analytics'])]
print('hot count:', len(hot))
for i,t in enumerate(hot[:25]):
    print(i, t['s'], '|', t['en'], '|', t.get('deg',''), '|', t.get('disc',''), '|', t.get('col',''))
