solution for ValueHistogram, SRM 565