Ã¢â¬â¹Given a number x, your task is to find if this number is Deficient number or not. A number x is said to be Deficient Number if sum of all the divisors of the number denoted by divisorsSum(x) is less than twice the value of the number x. And the difference between these two values is called the deficiency.
Mathematically, if below condition holds the number is said to be Deficient:
divisorsSum(x) < 2*x
deficiency = (2*x) - divisorsSum(x)
Example 1:
Input: x = 21
Output: YES 
Explanation: Divisors are 1, 3, 7 and
21.Sum of divisors is 32. 
This sum is less than 2*21 or 42.
Example 2:
Input: x = 12
Output: NO
Explanation: Divisors are 1, 2, 3, 4,
6 and 12.Sum of divisors is 28.
This sum is not less than 2*12 or 24.
Your Task:  
You dont need to read input or print anything. Complete the function isDeficient() which takes x as input parameter and returns YES if the number is Deficient otherwise returns NO.
Expected Time Complexity: O(sqrt(n))
Expected Auxiliary Space: O(1)
Constraints:
1<= x <=10000000

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(sqrt(n))
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3
class Solution:
    def isDeficient (self, x):
        # code here 

Solutions:
class Solution:

	def isDeficient(self, x):
		c = 0
		for i in range(1, x + 1):
			if x % i == 0:
				c += i
		if c < 2 * x:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def isDeficient(self, x):
		d = []
		for i in range(1, x + 1):
			if x % i == 0:
				d.append(i)
		e = sum(d)
		if e < 2 * x:
			return 'YES'
		return 'NO'


class Solution:

	def isDeficient(self, x):
		k = 1
		sm = 0
		while k <= x:
			if x % k == 0:
				sm = sm + k
			k = k + 1
		if sm < 2 * x:
			return 'YES'
		else:
			return 'NO'


class Solution:
	import math

	def isDeficient(self, x):
		l = []
		for i in range(1, x + 1):
			if x % i == 0:
				l.append(i)
		s = sum(l)
		a = 2 * x
		if s < a:
			return 'YES'
		else:
			return 'NO'


import math

class Solution:

	def isDeficient(self, x):

		def divisors(n):
			(res, lim) = ([], int(math.sqrt(n)))
			for i in range(1, lim + 1):
				if n % i == 0:
					if i == n / i:
						res.append(i)
					else:
						res.append(i)
						res.append(n // i)
			return res
		s = sum(divisors(x))
		if s >= 2 * x:
			return 'NO'
		return 'YES'


class Solution:

	def isDeficient(self, x):
		k = 0
		for i in range(1, int(x ** (1 / 2)) + 1):
			if x % i == 0:
				k = k + i + x / i
			else:
				continue
		if k < 2 * x:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def isDeficient(self, x):
		if x < 6:
			return 'YES'
		s = 1
		for i in range(2, x // 2 + 1):
			if not x % i:
				s += i
		if s < x:
			return 'YES'
		return 'NO'


class Solution:

	def isDeficient(self, x: int) -> str:
		sum_factors = sum(self.findFactors(x))
		if sum_factors < x:
			return 'YES'
		else:
			return 'NO'

	@staticmethod
	def findFactors(num: int) -> list:
		result = [1]
		for i in range(2, int(num ** 0.5) + 1):
			if num % i == 0:
				if num // i == i:
					result.append(i)
				else:
					if num % (num // i) == 0:
						result.append(num // i)
					result.append(i)
		return result


class Solution:

	def isDeficient(self, x):
		sum = 0
		i = 1
		while i * i <= x:
			if x % i == 0:
				sum += i
				if x // i != i:
					sum += x // i
			i += 1
		if sum < 2 * x:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def isDeficient(self, x):
		k = int(x ** 0.5)
		s = {}
		for i in range(1, k + 1):
			if x % i == 0:
				s[i] = 1
				s[x // i] = 1
		f = sum(s)
		if f < 2 * x:
			return 'YES'
		return 'NO'


class Solution:

	def isDeficient(self, x):
		l = []
		for i in range(1, x + 1):
			if x % i == 0:
				l.append(i)
		if sum(l) < x * 2:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def isDeficient(self, x):
		sum = 0
		str1 = 'YES'
		str2 = 'NO'
		for i in range(1, x):
			if x % i == 0:
				sum = sum + i
		if sum + x < 2 * x:
			return str1
		elif sum + x > 2 * x:
			return str2
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		x = int(input())
		ob = Solution()
		print(ob.isDeficient(x))


class Solution:

	def isDeficient(self, x):
		n = sum([i for i in range(1, x + 1) if x % i == 0])
		if n < x * 2:
			return 'YES'
		else:
			return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		x = int(input())
		ob = Solution()
		print(ob.isDeficient(x))


import math

class Solution:

	def isDeficient(self, x):
		sumis = 0
		for i in range(1, int(math.sqrt(x)) + 1):
			if x % i == 0:
				sumis += i + x // i
		if sumis < 2 * x:
			return 'YES'
		return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		x = int(input())
		ob = Solution()
		print(ob.isDeficient(x))


import math

class Solution:

	def isDeficient(self, x):
		g = self.factors(x)
		s = sum(g)
		if s < 2 * x:
			return 'YES'
		else:
			return 'NO'

	def factors(self, x):
		a = []
		for i in range(1, int(math.sqrt(x)) + 1):
			if x % i == 0:
				a.append(i)
				if x // i != i:
					a.append(x // i)
		return a
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		x = int(input())
		ob = Solution()
		print(ob.isDeficient(x))


import math

class Solution:

	def isDeficient(self, x):

		def getsum(n):
			sum = 0
			i = 1
			while i <= math.sqrt(n):
				if n % i == 0:
					if n // i == i:
						sum += i
					else:
						sum += i
						sum += n // i
				i += 1
			return sum
		if getsum(x) < 2 * x:
			return 'YES'
		return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		x = int(input())
		ob = Solution()
		print(ob.isDeficient(x))


import math

class Solution:

	def isDeficient(self, x):
		li = [1]
		k = int(math.sqrt(x)) + 1
		for i in range(2, k + 1):
			if x % i == 0 and i != x // i:
				li.append(i)
				li.append(x // i)
			elif x % i == 0 and i == x // i:
				li.append(i)
		li.append(x)
		if sum(li) < 2 * x:
			return 'YES'
		else:
			return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		x = int(input())
		ob = Solution()
		print(ob.isDeficient(x))


import math

class Solution:

	def isDeficient(self, x):
		sumDiv = 0
		n = int(math.sqrt(x))
		for i in range(1, n + 1):
			if x % i == 0:
				sumDiv += i
				sumDiv += x // i
		if sumDiv < x * 2:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def isDeficient(self, x):
		sum1 = 0
		for i in range(1, x + 1):
			if x % i == 0:
				sum1 += i
		y = x * 2
		if sum1 < y:
			return 'YES'
		return 'NO'


class Solution:

	def isDeficient(self, x):
		total = 0
		occ = set()
		for i in range(1, int(x ** 0.5) + 2):
			if x % i == 0:
				if i not in occ:
					total += i + int(x / i)
					occ.add(i)
					occ.add(int(x / i))
		return {True: 'YES', False: 'NO'}[x + x > total]


from math import *

class Solution:

	def isDeficient(self, x):
		l = []
		j = floor(x / 2) + 1
		for i in range(1, j):
			if x % i == 0:
				l.append(i)
		l.append(x)
		k = sum(l)
		if k < 2 * x:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def isDeficient(self, x):
		list1 = []
		for i in range(1, 10 ** 6):
			if x % i == 0:
				list1.append(i)
		k = sum(list1)
		g = list1[-1]
		if k < 2 * x:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def isDeficient(self, x):
		s = 1 + x
		for i in range(2, int(x ** 0.5) + 1):
			if x % i == 0:
				if x // i == i:
					s += i
				else:
					s += i + x // i
		if 2 * x > s:
			return 'YES'
		return 'NO'


class Solution:

	def isDeficient(self, x):
		a = []
		s = 0
		for i in range(1, x + 1):
			if x % i == 0:
				a.append(i)
		for i in a:
			s += i
		if s < 2 * x:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def isDeficient(self, x):
		k = 'YES'
		l = 'NO'
		s = 0
		for i in range(1, x + 1):
			if x % i == 0:
				s += i
		if 2 * x > s:
			return k
		else:
			return l


class Solution:

	def isDeficient(self, x):
		list = []
		for i in range(1, x + 1):
			if x % i == 0:
				list.append(i)
		s = sum(list)
		if s < 2 * x:
			return 'YES'
		return 'NO'