Generate program that has the following intention:

The intention of the program is to create a modified version of the input array arr such that the elements are sorted in descending order of their frequency in the original array, and the frequency of each element is represented by repeating its index in the sorted array.

Here's a step-by-step explanation of the program:

1. The function p3 takes two inputs: an array arr and an integer k.
2. k is the number of bins (or buckets) used for counting the elements in the array.
3. The counts list is initialized with zeros, with the length equal to k.
4. The program iterates through each element x in the arr array and increments the count of the corresponding NAME_1 (index x in the counts list).
5. The sorted_arr list is initialized as an empty list.
6. The program iterates through the counts list and extends the sorted_arr list by appending the index i (which corresponds to the NAME_1) repeated count times.
7. Finally, the sorted_arr list is returned as the modified version of the input array, where the elements are sorted in descending order of their frequency and the frequency of each element is represented by repeating its index in the sorted array.
