Given N, count all ‘a’(>=1) and ‘b’(>=0) that satisfy the condition a^{3} + b^{3 }= N.
 
Example 1:
Input:
N = 9 
Output:
2
Explanation:
There are two solutions: (a=1, b=2)
and (a=2, b=1).
Example 2:
Input:
N = 27
Output:
1
Explanation:
Thereis only one solution: (a=3, b=0)
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function pairCubeCount() which takes an Integer N as input and returns the answer.
 
Expected Time Complexity: O(cbrt(N))
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= N <= 10^{5}

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(cbrt(N))
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def pairCubeCount(self, N):
        # code here 

Solutions:
class Solution:

	def pairCubeCount(self, N):
		count = 0
		max_a = int(pow(N, 1 / 3)) + 1
		for a in range(1, max_a):
			b_cube = N - pow(a, 3)
			if b_cube < 0:
				break
			b = int(round(pow(b_cube, 1 / 3)))
			if pow(b, 3) == b_cube:
				count += 1
			if pow(a, 3) == N and b_cube == 0:
				count += 1
		if N == 1:
			count = 1
		return count


class Solution:

	def pairCubeCount(self, N):
		s = set()
		if N == 1:
			return 1
		count = 0
		for i in range(0, int(N ** (1 / 3)) + 1):
			r = N - i ** 3
			if round(r ** (1 / 3)) ** 3 == r:
				s.add(r)
				s.add(i ** 3)
		return len(s)


import math

class Solution:

	def pairCubeCount(self, N):
		c = 0
		a = N ** (1 / 3)
		if a > int(a):
			for i in range(1, int(a) + 1):
				for j in range(1, int(a) + 1):
					if math.pow(i, 3) + math.pow(j, 3) == N:
						c += 1
		elif a == int(a):
			c += 1
		return c


class Solution:

	def pairCubeCount(self, N):
		count = 0
		for a in range(1, int(N ** (1 / 3)) + 1):
			b = N - a ** 3
			if round(b ** (1 / 3)) ** 3 == b:
				count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		(ct, a) = (0, 1)
		while a ** 3 <= N:
			b = 0
			while b ** 3 <= N:
				if a ** 3 + b ** 3 == N:
					ct += 1
				b += 1
			a += 1
		return ct


import math

class Solution:

	def pairCubeCount(self, N):
		count = 0
		M = round(math.pow(N, 1 / 3))
		for i in range(1, M + 1):
			for j in range(M + 1):
				if i ** 3 + j ** 3 == N:
					count += 1
		return count


import math

class Solution:

	def pairCubeCount(self, N):
		count = 0
		a = math.floor(math.pow(N, 1 / 3))
		for i in range(0, a + 1):
			for j in range(1, a + 1):
				if i ** 3 + j ** 3 == N:
					count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		p = int(N ** (1 / 3)) + 1
		count = 0
		for i in range(1, p):
			for j in range(0, p):
				if i ** 3 + j ** 3 == N:
					count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		solutions = 0
		crN = int(N ** (1 / 3)) + 1
		for a in range(1, crN + 1):
			for b in range(0, a + 1):
				if a ** 3 + b ** 3 == N:
					if a == b or b == 0:
						solutions = solutions + 1
					else:
						solutions = solutions + 2
		return solutions


class Solution:

	def pairCubeCount(self, N):
		cube = int(N ** (1 / 3)) + 1
		c = 0
		for x in range(1, cube + 1):
			for y in range(cube + 1):
				if x ** 3 + y ** 3 == N:
					c += 1
		return c


class Solution:

	def pairCubeCount(self, N):
		(a, b) = (int(N ** (1 / 3)), int(N ** (1 / 3)))
		c = 0
		for i in range(1, a + 1):
			for j in range(b + 1):
				if i ** 3 + j ** 3 == N:
					c += 1
				elif i ** 3 + j ** 3 > N:
					break
		return c


import math

class Solution:

	def pairCubeCount(self, t):
		value = int(t ** (1 / 3))
		count = 0
		for i in range(1, value + 1):
			for j in range(0, value + 1):
				if i ** 3 + j ** 3 == t:
					count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		import math
		count = 0
		l = math.ceil(math.pow(N, 1 / 3))
		for i in range(1, l + 1):
			for j in range(0, l + 1):
				a = i * i * i
				b = j * j * j
				if a + b == N:
					count = count + 1
		return count


class Solution:

	def pairCubeCount(self, N):
		if N == 1:
			return 1
		count = 0
		floor_cbrt_N = 0
		while floor_cbrt_N ** 3 <= N:
			floor_cbrt_N += 1
		floor_cbrt_N -= 1
		for a in range(1, floor_cbrt_N + 1):
			b = N - a ** 3
			if b < 0:
				break
			cbrt_b = 0
			while cbrt_b ** 3 <= b:
				cbrt_b += 1
			if (cbrt_b - 1) ** 3 == b:
				count += 1
		return count


from itertools import product
import math

class Solution:

	def pairCubeCount(self, N):
		count = 0
		nums = [i for i in range(0, int(N ** (1 / 3)) + 1)]
		combs = [i for i in product(nums, repeat=2)]
		for i in combs:
			if i[0] ** 3 + i[1] ** 3 == N and i[0] >= 1 and (i[1] >= 0):
				count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		aset = set()
		i = 1
		while i <= N ** (1 / 3):
			aset.add(i * i * i)
			i += 1
		count = 0
		for ele in aset:
			if N - ele == 0 or N - ele in aset:
				count += 1
		return count


import math

class Solution:

	def pairCubeCount(self, N):
		res = int(N ** (1 / 3) + 1)
		count = 0
		for i in range(0, res):
			for j in range(1, res):
				if N == i ** 3 + j ** 3:
					count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		if N == 1:
			return 1
		a = {}
		b = []
		count = 0
		for i in range(N):
			if i not in a:
				a[i ** 3] = 1
				b.append(i)
		for i in b:
			if N - i ** 3 in a:
				count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		import math
		c = 0
		d = math.ceil(math.pow(N, 1 / 3))
		for i in range(1, d + 1):
			for j in range(d + 1):
				p = pow(i, 3) + pow(j, 3)
				if p == N:
					c += 1
		if c != 0:
			return c
		else:
			return 0


import math

class Solution:

	def pairCubeCount(self, N):
		count = 0
		for i in range(1, int(N ** (1 / 3)) + 1):
			bcube_root = (N - i ** 3) ** (1 / 3)
			if math.ceil(bcube_root) ** 3 == N - i ** 3:
				count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		c = 0
		if N == 1:
			return 1
		for i in range(1, int(pow(N, 1 / 3) + 1)):
			for j in range(0, int(pow(N, 1 / 3) + 1)):
				if i * i * i + j * j * j == N:
					c = c + 1
		return c


import math

class Solution:

	def pairCubeCount(self, N):
		if N == 1:
			return 1
		c = 0
		for a in range(1, int(N ** (1 / 3)) + 1):
			for b in range(0, int(N ** (1 / 3)) + 1):
				if a * a * a + b * b * b == N:
					c += 1
		return c
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.pairCubeCount(N))


class Solution:

	def pairCubeCount(self, N):
		c = 0
		temp = 0
		for i in range(1, int(N ** (1 / 3)) + 1):
			for j in range(int(N ** (1 / 3)) + 1):
				temp = i ** 3 + j ** 3
				if temp == N:
					c += 1
		return c
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.pairCubeCount(N))


class Solution:

	def pairCubeCount(self, N):
		k = int(N ** 0.3333333)
		a = []
		s = {}
		for i in range(0, k + 1):
			s[i] = i ** 3
			a.append(i)
		d = len(a)
		c = 0
		for i in range(1, d):
			for j in a:
				if s[a[i]] + s[j] == N:
					c += 1
		return c
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.pairCubeCount(N))


import math

class Solution:

	def pairCubeCount(self, N):
		c = 0
		l = math.ceil(math.pow(N, 1 / 3))
		for i in range(1, l + 1):
			for j in range(0, l + 1):
				if i ** 3 + j ** 3 == N:
					c = c + 1
		return c
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.pairCubeCount(N))


import math

class Solution:

	def pairCubeCount(self, N):
		sq = int(math.sqrt(N))
		count = 0
		if N <= 8:
			return 1
		for x in range(0, sq):
			for y in range(1, sq):
				if pow(x, 3) + pow(y, 3) == N:
					count = count + 1
		return count


import math

class Solution:

	def pairCubeCount(self, n):
		sq = int(math.sqrt(n))
		flag = 0
		if n <= 8:
			return 1
		for x in range(0, sq):
			for y in range(1, sq):
				if pow(x, 3) + pow(y, 3) == n:
					flag = flag + 1
		return flag


class Solution:

	def pairCubeCount(self, N):
		if N == 1:
			return 1
		count = 0
		for i in range(1, N):
			for j in range(N):
				if i * i * i + j * j * j == N:
					count += 1
				elif i * i * i + j * j * j > N:
					break
		return count


import math

class Solution:

	def pairCubeCount(self, N):
		count = 0
		i = 1
		while i * i * i <= N:
			j = 0
			while j * j * j <= N:
				if i * i * i + j * j * j == N:
					count += 1
				j += 1
			i += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		count = 0
		x = int(pow(N, 1 / 3))
		for i in range(1, x + 1):
			b = N - i * i * i
			if b == round(b ** (1 / 3)) ** 3:
				count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		x = int(N ** (1 / 3)) + 1
		ans = 0
		root = int(N ** (1 / 3))
		if root ** 3 == N:
			ans += 1
		for i in range(1, x):
			for j in range(1, x):
				if i ** 3 + j ** 3 == N:
					ans += 1
		return ans


import math

class Solution:

	def pairCubeCount(self, N):
		c = 0
		l = math.ceil(math.pow(N, 1 / 3))
		for i in range(1, l + 1):
			for j in range(0, l + 1):
				if i ** 3 + j ** 3 == N:
					c += 1
		return c


import numpy as np

class Solution:

	def pairCubeCount(self, N):
		count = 0
		for a in range(1, int(np.cbrt(N)) + 1):
			for b in range(0, int(np.cbrt(N) + 1)):
				if a ** 3 + b ** 3 == N:
					count += 1
		return count


import math

class Solution:

	def pairCubeCount(self, N):
		count = 0
		for b in range(int(N ** (1 / 3) + 1)):
			a = round((N - b ** 3) ** (1 / 3), 4)
			if a % 1 == 0 and a >= 1:
				count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		k = 0
		for a in range(1, int(pow(N, 1 / 3)) + 1):
			for b in range(0, int(pow(N, 1 / 3)) + 1):
				if pow(a, 3) + pow(b, 3) == N:
					k += 1
		return k


class Solution:

	def pairCubeCount(self, N):
		j = 0
		for i in range(1, int(pow(N, 1 / 3)) + 1):
			k = pow(N - pow(i, 3), 1 / 3)
			if (N - k) % 1 < pow(10, -7):
				j += 1
		return j


class Solution:

	def pairCubeCount(self, N):
		count = 0
		res1 = 0
		res2 = 0
		flag = 0
		cond = N
		if N == 0:
			return 0
		for i in range(1, N + 1):
			res1 = i * i * i
			if res1 <= N:
				for j in range(0, N):
					res2 = j * j * j
					if res2 < N:
						if res1 + res2 == N:
							count += 1
					else:
						flag = 1
						break
			else:
				break
		return count


import math

class Solution:

	def pairCubeCount(self, N):
		c = 0
		for i in range(1, int(math.sqrt(N) + 1)):
			for j in range(int(math.sqrt(N)) + 1):
				if i ** 3 + j ** 3 == N:
					c += 1
		return c


import math

class Solution:

	def pairCubeCount(self, N):
		count = 0
		for i in range(1, int(math.pow(N, 1 / 3) + 1)):
			cube = i * i * i
			diff = N - cube
			s_cube = round(math.pow(diff, 1 / 3))
			if s_cube * s_cube * s_cube == diff:
				count += 1
		return count


class Solution:

	def pairCubeCount(self, N):
		cubes_root = set()
		cubes_val = set()
		i = 0
		while i ** 3 <= N:
			cubes_root.add(i)
			cubes_val.add(i ** 3)
			i += 1
		return sum((N - i ** 3 in cubes_val and N - i ** 3 != 0 for i in cubes_root))


import math

class Solution:

	def pairCubeCount(self, N):
		if N == 1:
			return N
		count = 0
		cubRoot = round(N ** 1 / 3)
		for i in range(0, cubRoot + 1):
			aCube = i ** 3
			if aCube == N:
				count += 1
			else:
				if N - aCube == 1:
					ans = 1
				else:
					ans = round(math.pow(abs(N - aCube), 1 / 3))
				if ans ** 3 + aCube == N:
					count += 1
		return count


import math

class Solution:

	def pairCubeCount(self, N):
		count = 0
		i = 1
		while i * i * i <= N:
			cb = i * i * i
			if cb == N:
				count = count + 1
			else:
				val = N - cb
				out = math.ceil(val ** (1 / 3))
				if out ** 3 == val:
					count = count + 1
			i = i + 1
		return count


import math

class Solution:

	def pairCubeCount(self, N):
		k = math.floor(N ** (1 / 3))
		a = 1
		b = 0
		c = 0
		for i in range(1, k + 1):
			for j in range(k + 1):
				if i ** 3 + j ** 3 == N:
					c += 1
		return c


class Solution:

	def pairCubeCount(self, N):
		count = 0
		n = round(pow(N, 1 / 3)) + 1
		for i in range(1, n):
			for j in range(0, n):
				if pow(i, 3) + pow(j, 3) == N:
					count += 1
		if N == 1:
			return 1
		else:
			return count


class Solution:

	def pairCubeCount(self, N):
		m = int(N ** (1 / 3))
		M = m
		n = 0
		count = 0
		while m >= 0:
			for n in range(1, M + 1):
				if n ** 3 + m ** 3 == N:
					count = count + 1
			m = m - 1
		return count


class Solution:

	def pairCubeCount(self, N):
		(i, j, c) = (0, 0, 0)
		while i ** 3 <= N:
			j = 0
			while j ** 3 <= N:
				if j ** 3 + i ** 3 == N and j ** 3 != N:
					c = c + 1
				j = j + 1
			i = i + 1
		return c


import math

class Solution:

	def pairCubeCount(self, N):
		root_value = 3
		upper_limit = int(N ** (1 / root_value))
		count_sols = 0
		for i in range(1, upper_limit + 1):
			first_cube = i * i * i
			diff = N - first_cube
			cbrtdiff = math.ceil(diff ** (1 / 3))
			if cbrtdiff ** 3 == diff:
				count_sols += 1
		return count_sols


class Solution:

	def pairCubeCount(self, N):
		root_value = 3
		upper_limit = int(N ** (1 / root_value))
		count_sols = 0
		for i in range(0, upper_limit + 1):
			for j in range(1, upper_limit + 1):
				if j ** root_value + i ** root_value == N:
					count_sols += 1
		return count_sols


import math

class Solution:

	def pairCubeCount(self, N):
		count = 0
		for i in range(1, int(N ** (1 / 3)) + 1):
			cb = i * i * i
			diff = N - cb
			cbrtdiff = int(round(diff ** (1 / 3)))
			diffcb = cbrtdiff * cbrtdiff * cbrtdiff
			if diffcb == diff:
				count += 1
		return count