For this Question: Given an unsorted array A[] of integers and size N, and an element X, you need to find the Minimum Number of Elements required to be added to this array so the new median of array becomes X.
Median of array is middle element of array in its sorted form. For odd number of elements N it is the element at position (N-1)/2. For even number of elements N, it is (A[N/2] + A[(N/2) - 1])/2.

Try without sorting the arrayThe first line contains number of testcases T. Every testcase consists of 2 lines, first line contains N - no of element of arrays and X, and second line contains Array elements in unsorted manner.

Constraints:
1 <= T <= 100
1 <= N <= 2*10^5
1 <= X <= 10^6
1 <= A[i] <= 10^6

Sum of N for every test case is less than or equal to 2*10^5You need to find total number of elements to be added to array so that the new median becomes equal to X.Sample Input: 
2
6 30
10 20 30 100 150 200
5 50
10 20 30 100 150

Sample Output: 
1
1

Explanation: 
Testcase 1: Only 1 element before 30 is required to be added to the array, to make median of array 30.
Testcase 2: Only 1 element between 30 and 100, i. e number 70 is required to be added to make median 50., I have written this Solution Code: for i in range(int(input())):
	n,k=map(int,input().split())
	x=list(map(int,input().split()))
	count,large_count,small_count,small,large=0,0,0,-1,10000000
	for i in x:
		if i==k:
			count+=1
		if i>k:
			large_count+=1
			large=min(large,i)
		if i<k:
			small_count+=1
			small=max(small,i)
	ans=abs(large_count-small_count)
	if(count>0):
		if(count>=n/2):
			print(0)
		else:
			print(ans)
	elif(small_count==large_count):
		if((large+small)//2==k):
			print(0)
		else:
			print(1)
	elif(small_count==0 or large_count==0):
		print(n)
	else:
		t=2*k-small
		if(t==large):
			print(ans)
		elif(t<large):
			large_count+=1
			print(min(ans+1,abs(large_count-small_count)+1))
		elif(t>large):
			l=2*k-large
			if(l>small):
				small_count+=1
				print(min(ans+1,abs(large_count-small_count)+1))
			else:
				print(ans+1), In this Programming Language: Python, Now tell me if this Code is compilable or not?