After pulling my hair out, I have a couple of suggestions. The problem is to find the 'best estimate,' which I and many others attempting this problem took to be the mean expected value, the solution sought after historically. It's actually asking for the most likely single value. I suggest editing the problem description to make that clear.
I now see that the most likely value will always be m. In the process, I discovered that some of the test cases violate the assumptions of the problem, cases where the maximum value observed is less than the number of samples. I would correct this for the sake of those who don't immediately realize that the most likely single value will always be the maximum value observed.
The lack of clarity and problems with the test cases caused me to waste a good deal of time.