You are given a $sorted$ list $A$ of size  $N$.You have to make a new list $B$ such that $B[i]$ is equal to the number of elements $strictly$  $greater$ than $A[i]$ in the list $A$.
Print the $new$ $list$.

------ Input ------ 

The first line consists of  $T$, denoting the number of test cases.
First line of each test case consists of one integer denoting $N$, where $N$ is the size of the list given to you.

Second line of each test case contains the list given to you   containing $N$ elements.

------ Output ------ 

For each test case print the list in a single line and the elements of the list should be separated by  $space$.

Print the answer to $each$ test case in a $new$ $line$.

------ Constraints ------ 

$   $1 ≤ T ≤ 100$ , where $T$ is the number of test cases. $
$ $1 ≤ N ≤ 100$, where $N$ is the number of elements in the list.$
$$1 ≤ A[i] ≤ 1000000$ ,where $A[i]$ is the  $ith$ element in  the list given to you.$

------ Subtasks ------ 

$$15$ $points$: All the elements in the list given to you are distinct.$
$$35$ $points$: Original constraints: Elements can be repeated in the list.$

----- Sample Input 1 ------ 
2
4
1 2 4 4
5
1 2 2 2 2
----- Sample Output 1 ------ 
3 2 0 0
4 0 0 0 0
----- explanation 1 ------ 
The explanation for test case 1 of sample input :
The first element in the new list is 3 since the first element in the previous list was 1, and there are three elements which are strictly greater than 1, that is 2, 4 and 4.

The second element in the new list is 2 since the second element in the previous list was 2, and there are two elements which are strictly greater than 2, that is 4 and 4.

The third and fourth element in the new list is 0  since third and fourth element in the previous list was  4 and there are no elements which are strictly greater than them.

Source: codechef | Difficulty: EASY
Tags: Sorting

Complete search


Solutions:
goals = int(input())
for distractions in range(goals):
	life = int(input())
	wife = list(map(int, input().split()))
	knife = []
	death = 0
	for i in wife:
		for j in wife:
			if i != j and j > i:
				death += 1
		knife.append(death)
		death = 0
	print(*knife)


t = int(input())
for _ in range(t):
	n = int(input())
	integers = list(map(int, input().split()))
	ans = [0] * n
	for i in range(n):
		k = i + 1
		while k < n:
			if integers[i] == integers[k]:
				k += 1
			else:
				ans[i] = n - k
				break
	print(*ans)


for testcase in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	li = []
	c = 0
	for i in p:
		for j in p:
			if i != j and j > i:
				c += 1
		li.append(c)
		c = 0
	print(*li)


goals = int(input())
for distractions in range(goals):
	wife = int(input())
	life = list(map(int, input().split()))
	aim = []
	for stress in range(wife):
		death = 0
		for goal in range(stress + 1, wife):
			if life[goal] > life[stress]:
				death += 1
		aim.append(death)
	print(*aim)


for i in range(int(input())):
	N = int(input())
	l = list(map(int, input().split()))
	L = []
	for i in range(N):
		c = 0
		for k in range(i + 1, N):
			if l[k] > l[i]:
				c += 1
		L.append(c)
	print(*L)


T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	A = A[::-1]
	KEEP_GOING = True
	k = 0
	h = 0
	B = []
	while KEEP_GOING:
		a = A[k]
		c = A.count(a)
		for i in range(c):
			B.append(h)
		h += c
		k += c
		if k >= N:
			KEEP_GOING = False
	print(' '.join(map(str, B[::-1])))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	c = 0
	for i in a:
		for j in a:
			if i != j and j > i:
				c += 1
		l.append(c)
		c = 0
	print(*l)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	b = []
	for i in l:
		c = 0
		for j in l:
			if i < j:
				c += 1
		b.append(c)
	print(*b)


t = int(input())
for i in range(t):
	n = int(input())
	data = list(map(int, input().split()))
	lst = []
	for i in range(len(data)):
		cnt = 0
		for j in range(i + 1, len(data)):
			if data[i] < data[j]:
				cnt += 1
			else:
				pass
		lst.append(cnt)
		if len(lst) == n:
			print(*lst)


t = int(input())
for i in range(t):
	n = int(input())
	data = list(map(int, input().split()))
	lst = []
	for i in range(len(data)):
		cnt = 0
		for j in range(len(data)):
			if data[i] < data[j]:
				cnt += 1
			elif data[i] == data[j] and i != j:
				cnt += 0
		lst.append(cnt)
	print(*lst)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	a = []
	maxnum = max(l)
	for i in range(n):
		if l[i] == maxnum:
			a.append(0)
		else:
			a.append(n - l.index(l[i]) - l.count(l[i]))
	print(*a)


for i in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	B = ''
	for i in range(len(A)):
		c = 0
		for j in range(len(A)):
			if A[j] > A[i]:
				c += 1
			else:
				c = 0
		B = B + ' ' + str(c)
	print(B.strip())


l = int(input())
mpr = []
for yyb in range(0, l):
	k = int(input())
	fg = str(input())
	ttg = fg.split(' ')
	mpr.append(ttg)
for bbc in mpr:
	nbc = len(bbc)
	h = {}
	for mltr in bbc:
		if mltr not in h.keys():
			h[mltr] = 1
		else:
			h[mltr] += 1
	ans = []
	kltemp = []
	for ttew in bbc:
		eep = h[ttew]
		if ttew not in kltemp:
			nbc -= eep
			kltemp.append(ttew)
		ans.append(str(nbc))
	rr = ' '.join(ans)
	print(rr)


n = int(input())
for i in range(n):
	k = int(input())
	l = list(map(int, input().split()))
	p = []
	for j in l:
		c = 0
		for k in range(len(l)):
			if j < l[k]:
				c += 1
		p.append(c)
	for k in p:
		print(k, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	d = list(map(int, input().split()))
	s = []
	for i in range(len(d)):
		k = 0
		for j in range(len(d)):
			if d[i] < d[j]:
				k += 1
			elif d[i] == d[j] and i != j:
				k += 0
		s.append(k)
	print(*s)


for _ in range(0, int(input())):
	x = int(input())
	l = list(map(int, input().split()))
	a = []
	for i in range(0, x):
		c = 0
		for j in range(i, x):
			if l[j] > l[i]:
				c = c + 1
		a.append(c)
	print(*a)


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	B = [0] * N
	for i in range(N):
		c = 0
		for j in A:
			if j > A[i]:
				c += 1
		B[i] = c
	print(*B)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	c = 0
	for i in range(n):
		for j in a[i + 1:]:
			if j > a[i]:
				c += 1
		else:
			b.append(c)
			c = 0
	else:
		print(*b)


for x in range(0, int(input())):
	q = int(input())
	qrray = list(map(int, input().split()))
	list1 = []
	for x in range(0, q):
		count = 0
		for y in range(x + 1, q):
			if qrray[x] < qrray[y]:
				count += 1
		list1.append(count)
	for x in list1:
		print(x, end=' ')
	print()


for _ in range(int(input())):
	A = int(input())
	B = [int(x) for x in input().split()]
	C = []
	D = 0
	for i in B:
		for j in B:
			if i != j and j > i:
				D += 1
		C.append(D)
		D = 0
	print(*C)


for i in range(int(input())):
	N = int(input('\n'))
	L = list(map(int, input().split()))
	a = []
	for i in L:
		x = L.index(i) + L.count(i) - 1
		a.append(len(L) - x - 1)
	for j in a:
		print(j, end=' ')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	count = 0
	for i in a:
		for j in a:
			if j > i and i != j:
				count += 1
		b.append(count)
		count = 0
	print(*b)


for j in range(int(input())):
	n = int(input('\n'))
	li = list(map(int, input().split()))
	b = []
	for i in li:
		ans = li.index(i) + li.count(i) - 1
		b.append(len(li) - ans - 1)
	for item in b:
		print(item, end=' ')


for _ in range(int(input())):
	t = int(input())
	x = list(map(int, input().split()))
	c = 0
	d = []
	for i in x:
		for j in x:
			if i != j and j > i:
				c += 1
		d.append(c)
		c = 0
	print(*d)


t = int(input())
for tc in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = []
	for j in a:
		count = 0
		for k in range(n):
			if j < a[k]:
				count += 1
		c.append(count)
	for j in c:
		print(j, end=' ')
	print()


k = int(input())
for i in range(k):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in range(n):
		count = 0
		for j in range(n):
			if a[i] < a[j]:
				count += 1
		l.append(count)
	for i in l:
		print(i, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = 0
	an = []
	for y in l:
		for z in l:
			if y != z and z > y:
				m += 1
		an.append(m)
		m = 0
	print(*an)


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


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		count = 0
		for j in range(i + 1, n):
			if a[i] < a[j]:
				count += 1
		print(count, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	e = []
	d = 0
	for i in a:
		for j in a:
			if i != j and j > i:
				d += 1
		e.append(d)
		d = 0
	print(*e)


parag = int(input())
for distractions in range(parag):
	shree = int(input())
	shreee = list(map(int, input().split()))
	shreeee = []
	shreeeee = 0
	for i in shreee:
		for j in shreee:
			if i != j and j > i:
				shreeeee += 1
		shreeee.append(shreeeee)
		shreeeee = 0
	print(*shreeee)


T = int(input())
for i in range(T):
	N = int(input())
	list_a = list(map(int, input().split()))
	list_b = []
	for j in range(len(list_a)):
		count = 0
		for k in range(len(list_a)):
			if list_a[k] > list_a[j]:
				count += 1
		list_b.append(str(count))
	print(' '.join(list_b))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(n):
		k = 0
		for j in range(i, n):
			if l[i] < l[j]:
				k = k + 1
		l[i] = k
	print(' '.join((str(element) for element in l)))


for i in range(int(input())):
	n = int(input())
	b = []
	a = list(map(int, input().split()))
	for i in range(n):
		c = 0
		for j in range(len(a)):
			if a[i] < a[j]:
				c += 1
		b.append(c)
	for k in range(len(b)):
		print(b[k], end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	for j in range(len(l)):
		l1 = l[j:]
		print(len(l1) - l1.count(l[j]), end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	ans = []
	for i in range(n):
		c = 0
		for j in range(n):
			if lis[i] < lis[j]:
				c += 1
		ans.append(c)
	for i in ans:
		print(i, end=' ')
	print()


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	B = []
	c = 0
	for i in range(n):
		for j in range(n):
			if A[i] != A[j] and j > i:
				c += 1
		B.append(str(c))
		c = 0
	print(' '.join(B))


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	for i in range(n):
		c = 0
		for j in range(i, n):
			if a[j] > a[i]:
				c += 1
		sys.stdout.write(str(c) + ' ')
	sys.stdout.write('\n')


t = int(input())
for i in range(t):
	d = {}
	n = int(input())
	a = list(map(int, input().split()))
	a = a[::-1]
	for i in range(len(a)):
		if a[i] not in d:
			d[a[i]] = i
	for i in a[::-1]:
		print(d[i], end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = sorted(a)
	b = b[::-1]
	for j in a:
		print(b.index(j), end=' ')
	print()


for i in range(int(input())):
	input()
	nums = list(map(int, input().split()))
	c = 0
	res = []
	for i in nums:
		for j in nums:
			if i != j and j > i:
				c = c + 1
		res.append(c)
		c = 0
	print(*res)


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	for i in range(N):
		for j in range(i + 1, N):
			if A[i] < A[j]:
				A[i] = N - j
				break
		else:
			A[i] = 0
	print(*A)


goals = int(input())
for distractions in range(goals):
	num = int(input())
	alist = list(map(int, input().split()))
	blist = []
	count = 0
	for i in alist:
		for j in alist:
			if i != j and j > i:
				count += 1
		blist.append(count)
		count = 0
	print(*blist)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	for j in range(len(l)):
		c = 0
		for i in range(len(l)):
			if l[j] < l[i]:
				c = c + 1
			else:
				c += 0
		ans.append(str(c))
	x = ' '.join(ans)
	print(x)


for tc in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	l1 = []
	for i in l:
		a = 0
		for j in l:
			if i != j and j > i:
				a += 1
		l1.append(a)
	print(*l1)


class Solution:

	def __init__(self, n: int, arr: list) -> list:
		self.x = n
		self.li = arr

	def Answer(self):
		self.ans = []
		for i in range(self.x):
			self.cnt = 0
			for j in range(i + 1, self.x):
				if self.li[i] < self.li[j]:
					self.cnt += 1
			self.ans.append(self.cnt)
		return self.ans
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))[:n]
	ans = Solution(n, arr)
	print(*ans.Answer())


T = int(input())
for t in range(T):
	N = int(input())
	A = list((int(i) for i in input().split()))
	B = []
	for i in A:
		g = len(list(filter(lambda x: x > i, A)))
		B.append(g)
	print(*B)


t = int(input())
for i in range(t):
	N = int(input())
	A = list(map(int, input().split()))
	lis = []
	for x in range(N - 1):
		count = 0
		for j in range(x, N):
			if A[j] > A[x]:
				count += 1
		lis.append(count)
	lis.append(0)
	print(*lis)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(ele) for ele in input().split()]
	k = []
	s = 0
	for f in range(n):
		for j in range(1, n):
			if arr[f] < arr[j]:
				s += 1
		k.append(s)
		s = 0
	print(*k)


T = int(input())
while T:
	N = int(input())
	A = list(map(int, input().split()))
	B = []
	for i in range(N - 1):
		count = 0
		j = i + 1
		for j in range(N):
			if A[i] < A[j]:
				count += 1
		B.append(count)
	B.append(0)
	C = ' '.join(map(str, B))
	print(C)
	T -= 1


for i in range(int(input())):
	n = int(input())
	m = [int(i) for i in input().split()]
	f = 0
	for i in range(n):
		for j in range(i + 1, n):
			if m[i] < m[j]:
				f += 1
		print(f, end=' ')
		f = 0
	print()