Problem:


Counting Sort

Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:

Counting-Sort(A, B, k)
1    for i = 0 to k
2        do C[i] = 0
3    for j = 1 to length[A]
4        do C[A[j]] = C[A[j]]+1
5    /* C[i] now contains the number of elements equal to i */
6    for i = 1 to k
7    do C[i] = C[i] + C[i-1]
8    /* C[i] now contains the number of elements less than or equal to i */
9    for j = length[A] downto 1
10       do B[C[A[j]]] = A[j]
11          C[A[j]] = C[A[j]]-1

Write a program which sorts elements of given array ascending order based on the counting sort.

Input

The first line of the input includes an integer n, the number of elements in the sequence.

In the second line, n elements of the sequence are given separated by spaces characters.

Output

Print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.

Constraints

1 ≤ n ≤ 2,000,000

0 ≤ A[i] ≤ 10,000

Sample Input 1

7
2 5 1 3 2 3 0

Sample Output 1

0 1 2 2 3 3 5



Sample input:
7
2 5 1 3 2 3 0


Sample output:
0 1 2 2 3 3 5

Submission status: Runtime Error

Solution code:
n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200001)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
    try:
        A[i] = temp[i]
        if(A[i]>k):
            k=A[i]
        if(k>10000):
            break
    except IndexError:
        break
def cntSort(A, B, k):
    C = [0 for i in range(k)]
    for j in range(0, n):
        C[A[j]] += 1
    for i in range(1, k):
        C[i] += C[i-1]
    for i in range(n-1, -1, -1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)

Submission status: Runtime Error

Solution code:
n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200001)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
    try:
        A[i] = temp[i]
        if(A[i]>k):
            k=A[i]
        if(k>10000):
            break
    except IndexError:
        n = len(A[i])-1
        break
def cntSort(A, B, k):
    C = [0 for i in range(k)]
    for j in range(0, n):
        C[A[j]] += 1
    for i in range(1, k):
        C[i] += C[i-1]
    for i in range(n-1, -1, -1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)

Submission status: Runtime Error

Solution code:
n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200000)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
    try:
        A[i] = temp[i]
        if(A[i]>k):
            k=A[i]
        if(k>10000):
            break
    except IndexError:
        n = n-1
        break
def cntSort(A, B, k):
    C = [0 for i in range(k)]
    for j in range(0, n):
        C[A[j]] += 1
    for i in range(1, k):
        C[i] += C[i-1]
    for i in range(n-1, -1, -1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)

Submission status: Runtime Error

Solution code:
n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200000)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
    try:
        A[i] = temp[i]
        if(A[i]>k):
            k=A[i]
        if(k>10000):
            break
    except IndexError:
        n = n-1
        break
def cntSort(A, B, k):
    C = [0 for i in range(k)]
    for j in range(0, n):
        try:
            C[A[j]] += 1
        except IndexError:
            break
    for i in range(1, k):
        C[i] += C[i-1]
    for i in range(n-1, -1, -1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)

Submission status: Runtime Error

Solution code:
def countingsort(a,k):
    c=[0]*(k+1)
    n=len(a)
    for i in a:
        c[i]+=1
    for i in range(1,k+1):
        c[i]=c[i]+c[i-1]
    b=[0]*n
    for i in range(n-1,-1,-1):
        b[c[a[i]]-1]=a[i]
        c[a[i]]-=1
    return b
q=int(input())
a=list(map(int,input().split()))
ret=countingsort(a,q)
for i in range(len(ret)):
    if i!=len(ret)-1:
        print(ret[i],end=" ")
    else:
        print(ret[i])

Submission status: Runtime Error

Solution code:
def countingsort(a,k):
    c=[0]*(k+1)
    n=len(a)
    for i in a:
        c[i]+=1
    for i in range(1,k+1):
        c[i]=c[i]+c[i-1]
    b=[0]*n
    for i in range(n-1,-1,-1):
        b[c[a[i]]-1]=a[i]
        c[a[i]]-=1
    return b
o=int(input())
a=list(map(int,input().split()))
q=max(a)
ret=countingsort(a,q)
for i in range(n):
    if i!=n-1:
        print(ret[i],end=" ")
    else:
        print(ret[i])

Submission status: Runtime Error

Solution code:
#計数ソート
n = int(input())
a = list(map(int, input().split()))

def countSort(a):
    N = max(a)
    c = [0]*(N+2)
    b = [0]*len(a)
    for i in a:
        c[i] += 1
    for i in range(1,len(c)):
        c[i] += c[i-1]
        
    for i in a:
        b[c[i]-1] = i
        c[i] -= 1
    print(b)

countSort(*a)

Submission status: Runtime Error

Solution code:
def CountingSort(A,B,num):

	C = [0 for _ in range(num)]

	#C[i]にiの出現回数を記録する
	for i in A:
		C[i] += 1

	#C[i]にi以下の数の出現数を記録する =>累積度数分布を出力
	k = max(A)
	for j in range(k+1):
		C[j] += C[j-1]

	for h in range(k+1):
		B[C[A[h]]-1] = A[h]
		C[A[h]] -= 1

if __name__ == '__main__':

	num = int(input())
	A = [int(i) for i in input().split()]

	B = [0 for _ in range(num)]
	CountingSort(A,B,num)

	print(" ".join(map(str,B)))

Submission status: Runtime Error

Solution code:
def CountingSort(A,B,num):

	C = [0 for _ in range(num+1)]
	#C[i]にiの出現回数を記録する
	for i in A:
		C[i] += 1

	#C[i]にi以下の数の出現数を記録する =>累積度数分布を出力
	k = max(A)
	for j in range(1,k+1):
		C[j] += C[j-1]
	for h in range(num-1,-1,-1):
		B[C[A[h]]-1] = A[h]
		C[A[h]] -= 1

if __name__ == '__main__':

	num = int(input())
	A = [int(i) for i in input().split()]

	B = [0 for _ in range(num+1)]
	CountingSort(A,B,num)

	B.pop()
	print(" ".join(map(str,B)))

Submission status: Runtime Error

Solution code:


def counting_sort(A, k):
    B = [0 for i in range(len(A))]
    C = [0 for i in range(0, k + 1)]

    # C[i]???i???????????°????¨??????????
    for j in range(1, n):
        C[A[j]] += 1

    # C[i]???i??\????????°???????????°????¨??????????
    for i in range(1, k + 1):
        C[i] +=  C[i - 1]

    for j in reversed(range(1, n)):
        B[C[A[j]]] = A[j]
        C[A[j]] -= 1
    return B
n = int(input())
A = list(map(int, input().split()))
k = max(A)

print(counting_sort(A, B, k))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

def countSort(A, m):
    count = [0]*(m+1)
    n = len(A)
    B = [0]*m
    j = 0
    for i in range(n):
        count[A[i]] += 1
    for i in range(1, m):
        count[i] += count[i-1]
    for i in range(n-1, -1, -1):
        j = count[A[i]]
        B[j] = A[i]
        count[A[i]] = j-1
    for i in range(n):
        A[i] = B[i+1]
    return A

n = int(raw_input())
A = map(int, raw_input().split())
B = countSort(A, 10000)
print " ".join(map(str, B))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

def countSort(A, m):
    count = [0]*(m+1)
    n = len(A)
    B = [0]*2000000
    j = 0
    for i in range(n):
        count[A[i]] += 1
    for i in range(1, m):
        count[i] += count[i-1]
    for i in range(n-1, -1, -1):
        j = count[A[i]]
        B[j] = A[i]
        count[A[i]] = j-1
    for i in range(n):
        A[i] = B[i+1]
    return A

n = int(raw_input())
A = map(int, raw_input().split())
B = countSort(A, 10000)
print " ".join(map(str, B))

Submission status: Runtime Error

Solution code:

def counting_sort(target_list):
    counter = [0 for i in range(10000)]

    for n in target_list:
        counter[n] += 1

    for i in range(1,10000):
        counter[i] = counter[i] + counter[i-1]

    result = [0 for i in range(len(target_list))]
    for n in target_list[::-1]:
        result[counter[n] - 1] = n
        counter[n] -= 1
    
    return result
if __name__ == "__main__":
    n_list = int(input())
    target_list = [int(s) for s in input().split()]
    sorted_list = counting_sort(target_list)
    print(" ".join([int(s) for s in sorted_list]))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def counting_sort(A, k):
    B = [0] * k
    C = [0] * k
    for j in range(array_length):
        C[A[j]] += 1
    # print('1', C[:array_length])

    for i in range(1, k):
        C[i] += C[i - 1]
    # print('2', C[:array_length])

    for m in range(array_length - 1, -1, -1):
        B[C[A[m]]] = A[m]
        C[A[m]] -= 1

    return B[1:array_length + 1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    assert len(array) == array_length
    MAX_ELEM = int(1e4 + 1)
    result = counting_sort(A=array, k=MAX_ELEM)
    print(*result)

Submission status: Runtime Error

Solution code:
def CountingSort(A, k):
    C = [0] * k
    B = C[:]
    for a in A:
        C[a] += 1
    for i in range(1, len(C)):
        C[i] += C[i - 1]
    for i in range(len(A) - 1, -1, -1):
        B[C[A[i]]] = A[i]
        C[A[i]] -= 1
    return B



if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    sorted_A = CountingSort(A, int(10E4))
    print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]]))

Submission status: Runtime Error

Solution code:
def CountingSort(A, k):
    C = [0] * k
    B = C[:]
    for a in A:
        C[a] += 1
    for i in range(1, len(C)):
        C[i] += C[i - 1]
    for i in range(len(A) - 1, -1, -1):
        B[C[A[i]]] = A[i]
        C[A[i]] -= 1
    return B


if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    sorted_A = CountingSort(A, int(20E4))
    print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]]))

Submission status: Runtime Error

Solution code:
def CountingSort(A, k):
    C = [0] * k
    B = C[:]
    for a in A:
        C[a] += 1
    for i in range(1, len(C)):
        C[i] += C[i - 1]
    for i in range(len(A) - 1, -1, -1):
        B[C[A[i]]] = A[i]
        C[A[i]] -= 1
    return B




if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    sorted_A = CountingSort(A, int(3E10))
    print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]]))

Submission status: Runtime Error

Solution code:
def CountingSort(A, k):
    C = [0] * k
    B = C[:]
    for a in A:
        C[a] += 1
    for i in range(1, len(C)):
        C[i] += C[i - 1]
    for i in range(len(A) - 1, -1, -1):
        B[C[A[i]]] = A[i]
        C[A[i]] -= 1
    return B


fin = open('sample.txt')
input = fin.readline

if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    sorted_A = CountingSort(A, int(3E6))
    print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]]))

Submission status: Runtime Error

Solution code:
def counting_sort(array, maxval):
    m = maxval + 1
    count = [0] * (m)
    for a in array:
        count[a] += 1
    i = 0
    for a in range(m):
        for c in range(count[a]):
            array[i] = a
            i += 1
    return array
 
if __name__ == '__main__':
    N = int(input())
    l = list(map(int, input().split()))
    
    a = 0
    li = counting_sort(l, N)
    
    for a in range(N-1):
        print(li[a], end=" ") 
    
    print(li[N-1])

Submission status: Runtime Error

Solution code:
def CountingSort(A, B, k):
    C = [0 for i in range(k+2)]
    
    for j in range(n):
        C[A[j]] += 1
        
    for i in range(k+1):
        C[i] += C[i-1]
        
    for j in range(n-1, -1, -1):
        B[C[A[j]]-1] = A[j]
        C[A[j]] -= 1

if __name__=="__main__":
    n = int(input())
    D = list(map(int, input().split()))
    l = max(D)
    E = D[:]
    CountingSort(D, E, l)
    print(" ".join(map, str(E))))

Submission status: Runtime Error

Solution code:
# coding=utf-8
def counting_sort(input_list: list, upper: int) -> list:
    number = len(input_list)

    # noinspection PyUnusedLocal
    b = [0 for i in range(number+1)]
    # noinspection PyUnusedLocal
    counter_list = [0 for i in range(upper+1)]

    for j in input_list:
        counter_list[j] += 1

    for i in range(k+1):
        counter_list[i] += counter_list[i-1]

    for j in range(number):
        b[counter_list[input_list[j]]] = input_list[j]
        counter_list[input_list[j]] -= 1

    return b


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    k = 100
    a = counting_sort(a, k)
    a.pop(0)

    print(' '.join(map(str, a)))

Submission status: Runtime Error

Solution code:
def counting_sort(A, B, k):
    C = [0 for _ in xrange(k+1)]
    for a in A:
        C[a] += 1

    for i in xrange(k):
        C[i] = C[i] + C[i-1]

    for i in xrange(n-1, -1, -1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1


n = int(raw_input())
A = map(int, raw_input().split())
B = [0 for _ in xrange(n)]

counting_sort(A, B, 10000)

print " ".join(map(str, B)

Submission status: Runtime Error

Solution code:
def counting_sort(A, k):
    C = [0 for i in range(k)]
# C[i]にiの出現数を記録する
    for l in A:
        C[l] += 1
# C[i]にi以下の数の出現数を記録する
    for i in range(1, k):
        C[i] = C[i] + C[i-1]

    B = [None for i in range(len(A))]
    for l in A[::-1]:
        B[C[l]-1] = l
        C[l] -= 1

    return B

input()
a = list(map(int, input().split()))
b = counting_sort(a, 10)
print(*b)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))


def countingsort(a, k):
    c = [0 for i in range(k)]
    b = [0 for i in range(n)]

    for j in range(n):
        c[a[j]] += 1

    for i in range(k):
        c[i+1] += c[i]

    for j in reversed(range(n)):
        b[c[a[j]]] = a[j]
        c[a[j]] -= 1
    
    return b

b = countingsort(a, 10001)
print(*b)

Submission status: Runtime Error

Solution code:
def counting_sort(A, k):
    n = len(A)
    B = [0 for i in range(n)]
    C = [0 for i in range(k+1)]

    for j in range(n):
        C[A[j]] += 1

    for i in range(1, k):
        C[i] = C[i] + C[i-1]

    for j in range(n-1, -1, -1):
        B[C[A[j]]-1] = A[j]
        C[A[j]] -= 1

    return B

n = int(input())
A = list(map(int, input().split(' ')))
B = counting_sort(A, 6)
print(' '.join(map(str, B)))

Submission status: Runtime Error

Solution code:
n = int(input())
s = list(map(int, input().split()))
k = len(set(s))
c = [0 for i in range(k+1)]
def counting_sort(a, k):
    global c
    b = [0 for i in range(len(a)+1)]
    for i in range(n):
        c[a[i]] += 1

    for i in range(1,k+1):
        c[i] = c[i] + c[i - 1]

    for i in reversed(range(n)):
        b[c[a[i]]] = a[i]
        c[a[i]] -= 1
    return b
res = counting_sort(s, k)[1:n+1]
print(*res)

Submission status: Runtime Error

Solution code:
#coding:utf-8

n = int(input())
A = list(map(int, input().split()))
k = 10000
C = [0 for i in range(k)]
B = [0 for i in range(n)]

def CountingSort(A,B,k):
    for i in range(n):
        C[A[i]] += 1
    for i in range(k):
        C[i] += C[i-1]
    for i in range(n):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1

CountingSort(A,B,k)
B = " ".join([str(num) for num in B])
print(B)

Submission status: Runtime Error

Solution code:
#coding:utf-8

n = int(input())
A = list(map(int, input().split()))
k = 10000
C = [0 for i in range(k)]
B = [0 for i in range(n)]

def CountingSort(A,B,k):
    for i in range(n):
        C[A[i]] += 1
    for i in range(k):
        C[i] += C[i-1]
    for i in range(n-1,-1,-1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1

CountingSort(A,B,k)
B = " ".join([str(num) for num in B])
print(B)

Submission status: Runtime Error

Solution code:
#coding:utf-8

n = int(input())
A = list(map(int, input().split()))
k = 10000
C = [0 for i in range(k)]
B = [0 for i in range(n)]

def CountingSort(A,B,k):
    for i in range(n):
        C[A[i]] += 1
    for i in range(k):
        C[i] += C[i-1]
    for i in range(n):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1

CountingSort(A,B,k)
B = " ".join([str(num) for num in B])
print(B)

Submission status: WA: Presentation Error

Solution code:
n = int(input())
l = list(map(int,input().split()))
bucket = [0]*n
for i in range(n):
    for j in range(n):
        if i == l[j]:
            bucket[i] += 1
for i in range(n):
    for j in range(bucket[i]):
        print(i,end = ' ')
print()

Submission status: WA: Presentation Error

Solution code:
n = int(input())
l = list(map(int,input().split()))
bucket = [0]*n
for i in range(n):
    for j in range(n):
        if i == l[j]:
            bucket[i] += 1
for i in range(n):
    for j in range(bucket[i]):
        print(i,end = ' ')
print()

Submission status: WA: Presentation Error

Solution code:
def printAns( A ):
    n = len(A)
    for i in range(1, n-1):
        print( str( A[i] ), end=" ")
    print( str( A[n-1] ), end="" )

def main():
    n = int( input() )
    A = [0]
    list = [int(x) for x in input().split()]
    A.extend(list)
    B = []
    C = []
    k = max(A)

    for i in range(k + 1):
        C.append(0)

    for i in range(n+1):
        B.append(0)

    for j in range(1, n+1):
        C[ A[j] ] += 1

    for i in range(1, k+1):
        C[i] = C[i] + C[i-1]

    for j in reversed(range(n+1)):
        B[ C[ A[j] ] ] = A[j]
        C[ A[j] ] -= 1

    printAns(B)

if __name__ == "__main__":
    main()

Submission status: WA: Presentation Error

Solution code:
def counting_Sort(lineA,k,n):
    lineB = []
    lineC = []

    for i in range(len(lineA)):
        lineB.append(0)

    i = 0
    while i < k:
        i = i + 1
        lineC.append(0)

    j = 0
    while j < n:
        lineC[lineA[j]] = lineC[lineA[j]] + 1
        j = j + 1

    i = 1
    while i < k:
        lineC[i] = lineC[i] + lineC[i-1]
        i = i + 1

    j = n - 1
    while j >= 0:
        lineB[lineC[lineA[j]] - 1] = lineA[j]
        lineC[lineA[j]] = lineC[lineA[j]] - 1
        j = j - 1

    return lineB



n = int(input())
lineA = list(map(int,input().split()))
if len(lineA) != n:
    print("Error")
    exit()
lineA = counting_Sort(lineA,max(lineA)+1,n)

for i in range(len(lineA)):
    if i != len(lineA):
        print(lineA[i],end=" ")
    else:
        print(lineA[i],end="")

Submission status: WA: Presentation Error

Solution code:
def counting_Sort(lineA,k,n):
    lineB = []
    lineC = []

    for i in range(len(lineA)):
        lineB.append(0)

    i = 0
    while i < k:
        i = i + 1
        lineC.append(0)

    j = 0
    while j < n:
        lineC[lineA[j]] = lineC[lineA[j]] + 1
        j = j + 1

    i = 1
    while i < k:
        lineC[i] = lineC[i] + lineC[i-1]
        i = i + 1

    j = n - 1
    while j >= 0:
        lineB[lineC[lineA[j]] - 1] = lineA[j]
        lineC[lineA[j]] = lineC[lineA[j]] - 1
        j = j - 1

    return lineB



n = int(input())
lineA = list(map(int,input().split()))
if len(lineA) != n:
    print("Error")
    exit()
lineA = counting_Sort(lineA,max(lineA)+1,n)

for i in range(len(lineA)):
    if i != len(lineA):
        print(lineA[i],end=" ")
    else:
        print(lineA[i],end="")
        print()

Submission status: WA: Presentation Error

Solution code:
def counting_Sort(lineA,k,n):
    lineB = []
    lineC = []

    for i in range(len(lineA)):
        lineB.append(0)

    i = 0
    while i < k:
        i = i + 1
        lineC.append(0)

    j = 0
    while j < n:
        lineC[lineA[j]] = lineC[lineA[j]] + 1
        j = j + 1

    i = 1
    while i < k:
        lineC[i] = lineC[i] + lineC[i-1]
        i = i + 1

    j = n - 1
    while j >= 0:
        lineB[lineC[lineA[j]] - 1] = lineA[j]
        lineC[lineA[j]] = lineC[lineA[j]] - 1
        j = j - 1

    return lineB



n = int(input())
lineA = list(map(int,input().split()))
if len(lineA) != n:
    print("Error")
    exit()
lineA = counting_Sort(lineA,max(lineA)+1,n)

for i in range(len(lineA)):
    if i != len(lineA):
        print(lineA[i],end=" ")
    else:
        print(lineA[i])

Submission status: WA: Presentation Error

Solution code:
def counting_Sort(lineA,k,n):
    lineB = []
    lineC = []

    for i in range(len(lineA)):
        lineB.append(0)

    i = 0
    while i < k:
        i = i + 1
        lineC.append(0)

    j = 0
    while j < n:
        lineC[lineA[j]] = lineC[lineA[j]] + 1
        j = j + 1

    i = 1
    while i < k:
        lineC[i] = lineC[i] + lineC[i-1]
        i = i + 1

    j = n - 1
    while j >= 0:
        lineB[lineC[lineA[j]] - 1] = lineA[j]
        lineC[lineA[j]] = lineC[lineA[j]] - 1
        j = j - 1

    return lineB



n = int(input())
lineA = list(map(int,input().split()))
if len(lineA) != n:
    print("Error")
    exit()
lineA = counting_Sort(lineA,max(lineA)+1,n)

for i in range(len(lineA)):
    print(lineA[i],end=" ")

Submission status: WA: Presentation Error

Solution code:
# -*- coding: utf-8 -*-
def counting_sort(array, maxval):
    m = maxval + 1
    count = [0] * (m) 
    for a in array:
        count[a] += 1             # ???????????°????¨????
    i = 0
    for a in range(m):            # ???????????§????????§??°?????????
        for c in range(count[a]): # ?????????????????°????????°???????????????????????????????????????????????????
            array[i] = a
            i += 1
    return array
 
if __name__ == '__main__':
    N = int(input())
    l = list(map(int, input().split()))
    
    a = 0
    li = counting_sort(l, N)
    
    for a in range(N):
        print(li[a], end=" ")

Submission status: WA: Presentation Error

Solution code:
def CountingSort(A):
    B = [0]*len(A)
    maxnumber = 0
    for n in range(len(A)):
        if maxnumber < A[n]:
            maxnumber = A[n]
    C = [0]*(maxnumber + 1)

    for j in range(len(A)):
        C[A[j]] += 1
    for r in range(1, maxnumber+1):
        C[r] = C[r] + C[r-1]

    for s in range(len(A))[::-1]:
        B[C[A[s]]-1] =A[s]
        C[A[s]] -= 1

    return B


if __name__ == '__main__':
    cnt = input()
    A = list(map(int,input().split()))
    Ans = CountingSort(A)
    for y in Ans:
        print("{} ".format(y), end="")

Submission status: WA: Presentation Error

Solution code:
def CountingSort(A):
    B = [0]*len(A)
    maxnumber = 0
    for n in range(len(A)):
        if maxnumber < A[n]:
            maxnumber = A[n]
    C = [0]*(maxnumber + 1)

    for j in range(len(A)):
        C[A[j]] += 1
    for r in range(1, maxnumber+1):
        C[r] = C[r] + C[r-1]

    for s in range(len(A))[::-1]:
        B[C[A[s]]-1] =A[s]
        C[A[s]] -= 1

    return B


if __name__ == '__main__':
    cnt = input()
    A = list(map(int,input().split()))
    Ans = CountingSort(A)
    for y in Ans:
        print("{} ".format(y), end="")
    print()

Submission status: WA: Presentation Error

Solution code:
input()
A=list(map(int,input().split()))
C=[0]*(max(A)+1)
for a in A:C[a]+=1
print(' '.join(''.join(str(i)*k for i,k in enumerate(C))))