```-rwxr-xr-x 1500 high-ctidh-20210504/analyze-costs#!/usr/bin/env python3

import sys
import math

def mean(d):
return sum(d)*1.0/len(d)

def deviation(d):
m = mean(d)
return math.sqrt(sum((x-m)**2 for x in d)*1.0/len(d))

keys = set()
validate = {}
action = {}
num = 0

for line in sys.stdin:
line = line.split()
if len(line) < 11: continue
if line[3] != 'mulsq': continue
if line[5] != 'sq': continue
if line[7] != 'addsub': continue
if line[9] != 'cycles': continue

if line[2] == 'validate':
target = validate
elif line[2] == 'action':
target = action
else:
continue

mulsq = int(line[4])
sq = int(line[6])
Mcyc = 0.000001*int(line[10])
mul = mulsq-sq

for k in int(line[1]),'total':
for name,value in (
('Mcyc',Mcyc),
('mulsq',mulsq),
('sq',sq),
('mul',mul),
('combo185',combo185),
):
if (k,name) not in target:
target[k,name] = []
target[k,name] += [value]

num += 1

for k in sorted(keys)+['total']:
for targetname,target in (
('validate',validate),
('action',action),
):
output = '%s %s' % (k,targetname)
output += ' experiments %d' % len(target[k,'Mcyc'])
for name in ('Mcyc','mulsq','sq','addsub','mul','combo185'):
x = target[k,name]
format = ' %s %.0f+-%.0f'
if name == 'Mcyc':
format = ' %s %.2f+-%.2f'
output += format%(name,mean(x),deviation(x))
print(output)
```