#!/usr/bin/perl
use 5.016;
use warnings;
sub chunk {
my @l;
foreach(0 .. $#_){
push @{$l[$_ / $n]}, $_[$_]; }
}
sub f
{ map{ $_->[1] . len
($_->[0]) } chunk
(2, shift =~ m/\G((.)\2*)/g) }
say f("aaaaaaaaaabbbbbbbbbbbbcccccccddddddddddeeeeeeefffffffffghiiiiiiiii");
IyEvdXNyL2Jpbi9wZXJsCnVzZSA1LjAxNjsKdXNlIHdhcm5pbmdzOwoKc3ViIGNodW5rIHsKCW15ICRuID0gc2hpZnQ7CgoJbXkgQGw7Cglmb3JlYWNoKDAgLi4gJCNfKXsKCQlwdXNoIEB7JGxbJF8gLyAkbl19LCAkX1skX107Cgl9CgoJcmV0dXJuIEBsOwp9CgpzdWIgbGVuIHsgbGVuZ3RoKCRfWzBdKSA+IDEgPyBsZW5ndGgoJF9bMF0pIDogJycgfQoKc3ViIGYgeyBtYXB7ICRfLT5bMV0gLiBsZW4oJF8tPlswXSkgfSBjaHVuaygyLCBzaGlmdCA9fiBtL1xHKCguKVwyKikvZykgfQoKc2F5IGYoImFhYWFhYWFhYWFiYmJiYmJiYmJiYmJjY2NjY2NjZGRkZGRkZGRkZGVlZWVlZWVmZmZmZmZmZmZnaGlpaWlpaWlpaSIpOwo=