The first mistake in your code is, the declaration of array B. Since A[i]<=10000, that means B may be accessed according to the input which you’ll not be able to since the maximum size of B by your code is 10000. So, you need to change that to 10001.
Contrary test case:
10000 13 10000 13 10000 10000 // output is 13 2 as per your code
Then, the question says if two or more numbers with same count exists, you need to output the smallest. You’re not doing this check.