#!/usr/bin/perl

$|=1;
%alist = ("Reading Mail", [7.80, 7.70, 1.28, 1.63, 3.945, 3.678, 4.24, 1.63, .15, .14, .37, .40, .35, .64, .09, .13, .42],
	  "Idle", [4.07, 3.98, 1.44, 5.25, 4.33, 4.33, 1.5, 5.25, 0, 0, 0, 0.01, 0.05, 0.08, 0.06, 0.2, 0.26],
	  "Web Browsing", [6.58, 6.59, 11.57, 12.4, 4.934, 4.845, 12.8, 12.4, 0.06, 0.06, .16, .17, .18, .38, .24, .28, .64],
	  "Coding", [7.48, 7.50, 1.81, 2.18, 5.05, 5.05, .95, 2.18, 1.86, 1.88, 1.8, .8, .82, 1.3, .02, .03, .11],
	  );

%scale = ("Reading Mail", 1.2,
	  "Idle", .1,
	  "Web Browsing", 1,
	  "Coding", 1);

while(<>){
    split;
    @x = @_;
    $x[0] = $x[0]/100;
    $x[1] = $x[1]/100;
    $x[4] = $x[4]/100;
    $x[5] = $x[5]/100;
    $best = 10000000000;
    foreach $a (keys %alist){
	$dist = &dist(\@x, $alist{$a});
	$dist = $dist/$scale{$a};
	print "$a($dist), ";
	if($dist < $best){
	    $best = $dist;
	    $bact = $a;
	}
    }
    print ": $bact\n";
}

sub dist {
    @cur = @{$_[0]};
    @cmp = @{$_[1]};
    
    $tot=0;
    for $n (0..$#cur){
	$tot+= ($cur[$n]-$cmp[$n])**2;
    }
    return sqrt($tot/($#cur+1));
}
