Generate program that has the following intention:

The intention of the program below is to create a new sorted list of integers based on the frequency of each integer in the input list. The function p3(NAME_1, k) takes two arguments: NAME_1, which is a list of integers, and k, which is the number of distinct integers in the input list.

The function does the following:

1. Initializes an array counts of length k and sets all elements to 0. This will store the frequency count of each unique integer in the input list.
2. Iterates through each element x in the input list NAME_1 and increments the corresponding count in the counts array.
3. Initializes an empty list sorted_NAME_1.
4. Iterates through the counts array and the input list NAME_1 in tandem. For each integer i and its frequency count count, it appends count number of i to the sorted_NAME_1 list.
5. Returns the sorted list sorted_NAME_1.

The function essentially creates a new sorted list where each integer in the input list NAME_1 is repeated according to its frequency in the counts array. Write your response with exactly 4 paragraphs, separated with the markdown divider: ***.
user