#!/usr/bin/perl
use 5.016;
use warnings;
use List
::Util qw(reduce
);
sub count { reduce{ $a->{$b}++; $a } {}, @_ }
sub max_key
{ reduce
{ $_[0]->{$a} > $_[0]->{$b} ? $a : $b } keys %{$_[0]} }
say f("aabaabbab");
IyEvdXNyL2Jpbi9wZXJsCnVzZSA1LjAxNjsKdXNlIHdhcm5pbmdzOwp1c2UgTGlzdDo6VXRpbCBxdyhyZWR1Y2UpOwoKc3ViIGNvdW50IHsgcmVkdWNleyAkYS0+eyRifSsrOyAkYSB9IHt9LCBAXyB9CnN1YiBtYXhfa2V5IHsgcmVkdWNleyAkX1swXS0+eyRhfSA+ICRfWzBdLT57JGJ9ID8gJGEgOiAkYiB9IGtleXMgJXskX1swXX0gfQpzdWIgZiB7IG1heF9rZXkgY291bnQgc3BsaXQgLy8sIHNoaWZ0IH0KCnNheSBmKCJhYWJhYWJiYWIiKTsK