Chef has recently been playing a lot of chess in preparation for the ICCT (International Chef Chess Tournament).
Since putting in long hours is not an easy task, Chef's mind wanders elsewhere. He starts counting the number of squares with odd side length on his chessboard..
However, Chef is not satisfied. He wants to know the number of squares of odd side length on a generic $N*N$ chessboard.

-----Input:-----
- The first line will contain a single integer $T$, the number of test cases.
- The next $T$ lines will have a single integer $N$, the size of the chess board.

-----Output:-----
For each test case, print a integer denoting the number of squares with odd length.

-----Constraints-----
- $1 \leq T \leq 100$
- $1 \leq N \leq 1000$

-----Sample Input:-----
2
3
8

-----Sample Output:-----
10
120

Source: codechef | Difficulty: MEDIUM
Tags: Combinatorics

Mathematics


Solutions:
t = int(input())
for i in range(t):
	a = 0
	n = int(input())
	while n > 0:
		a += n * n
		n = n - 2
	print(a)


T = int(input())
for i in range(0, T):
	num = int(input())
	answer = 0
	for j in range(1, num + 1):
		if j % 2 != 0:
			answer += (num - j + 1) ** 2
	print(answer)


n = int(input())
for x in range(n):
	a = int(input())
	count = 0
	while a > 0:
		count += a * a
		a -= 2
	print(count)


for _ in range(int(input())):
	n = int(input())
	count = 0
	for i in range(1, n + 1, 2):
		k = n - i + 1
		count += k * k
	print(count)


for _ in range(int(input())):
	N = int(input())
	ans = 0
	for i in range(1, N + 1, 2):
		ans += (N - i + 1) ** 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	cnt = 0
	for i in range(1, n + 1, 2):
		s = n + 1 - i
		cnt = cnt + s * s
	print(cnt)


for _ in range(int(input())):
	n = int(input())
	i = 1
	res = 0
	while i <= n:
		res += (n - i + 1) ** 2
		i += 2
	print(res)


for _ in range(int(input())):
	a = int(input())
	sum = 0
	while a > 0:
		sum = sum + a * a
		a = a - 2
	print(sum)


for _ in range(int(input())):
	P = int(input())
	squares = 0
	for i in range(1, P + 1, 2):
		size = P - i + 1
		squares += size * size
	print(squares)


n = int(input())
for _ in range(n):
	curr = int(input())
	sum = 0
	while curr > 0:
		sum += curr ** 2
		curr -= 2
	print(sum)


for _ in range(int(input())):
	n = int(input())
	s = 0
	if n % 2 == 0:
		for i in range(2, n + 1, 2):
			s = s + i * i
	else:
		for i in range(1, n + 1, 2):
			s = s + i * i
	print(s)


n = int(input())
for i in range(n):
	odd = int(input())
	count = 0
	if odd % 2 != 0:
		for i in range(1, odd + 1, 2):
			count += i * i
		print(count)
	else:
		for j in range(0, odd + 1, 2):
			count += j * j
		print(count)


t = int(input())
for q in range(t):
	a = int(input())
	sum = 0
	for i in range(1, a + 1):
		if i % 2 != 0:
			sum += (a - i + 1) ** 2
		else:
			pass
	print(sum)


for test in range(int(input())):
	N = int(input())
	summy = 0
	while N > 0:
		summy += N ** 2
		N = N - 2
	print(summy)


def count(size, box):
	num = size - box + 1
	return num * num
for tc in range(int(input())):
	n = int(input())
	c = 0
	for i in range(1, n + 1, 2):
		c += count(n, i)
	print(c)


for i in range(int(input())):
	x = int(input())
	s = 0
	for j in range(x, 0, -2):
		s += j ** 2
	print(s)


for i in range(0, int(input())):
	n = int(input())
	odd = 0
	for i in range(1, n + 1):
		if i % 2 != 0:
			odd += (n - (i - 1)) ** 2
	print(odd)


for _ in range(int(input())):
	n = int(input())
	t = n
	s = 0
	while t > 0:
		s = s + t * t
		t = t - 2
	print(s)


for t in range(int(input())):
	n = int(input())
	e = n // 2
	o = (n + 1) // 2
	if n & 1 == 0:
		ans = 2 * e * (e + 1) * (2 * e + 1) // 3
		print(ans)
	else:
		ans = o * (2 * o + 1) * (2 * o - 1) // 3
		print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	ans = 0
	if n % 2 == 0:
		for j in range(n + 1):
			if j % 2 == 0:
				ans += j ** 2
	else:
		for j in range(n + 1):
			if j % 2 != 0:
				ans += j ** 2
	print(ans)


for _ in range(int(input())):
	k = int(input())
	if k % 2 == 0:
		n = k - 1
	else:
		n = k
	s = 0
	while n > 0:
		s += (k - n + 1) ** 2
		n -= 2
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	tot = n * n
	for i in range(3, n + 1):
		if i % 2 != 0:
			tot += (n - i + 1) ** 2
	print(tot)


for x in range(int(input())):
	N = int(input())
	total = 0
	for i in range(1, N + 1, 2):
		total += (N + 1 - i) * (N + 1 - i)
	print(total)


t = int(input())
for _ in range(t):
	n = int(input())
	res = 0
	for i in range(n, 0, -2):
		res += i * i
	print(res)


t = int(input())
i = 0
while i < t:
	ans = 0
	flag = 1
	n = int(input())
	for j in range(0, n, 2):
		if n - j != 0:
			ans = ans + (n - j) * (n - j)
		else:
			break
	print(ans)
	i += 1


for i in range(int(input())):
	a = int(input())
	x = 0
	for i in range(1, a + 1, 2):
		x = x + (a - i + 1) ** 2
	print(x)


T = int(input())
for i in range(T):
	N = int(input())
	ans = 0
	while N >= 1:
		ans += N * N
		N -= 2
	print(ans)


for _ in range(int(input())):
	t = int(input())
	sum = 0
	for i in range(t, 0, -2):
		sum += i * i
	print(sum)


for i in range(int(input())):
	n = int(input())
	cnt = 0
	for j in range(1, n + 1):
		if j % 2 == 1:
			cnt += (n - j + 1) ** 2
	print(cnt)


T = int(input())
for i in range(T):
	(N, O) = (int(input()), 0)
	for j in range(1, N + 1, 2):
		O += (N + 1 - j) ** 2
	print(O)


for i in range(int(input())):
	n = int(input())
	if n % 2 == 0:
		n = n // 2
		sz = 4 * (n * (n + 1) * (2 * n + 1)) // 6
		print(sz)
	else:
		n = n + 1
		a1 = n * (n + 1) * (2 * n + 1) // 6
		n = n // 2
		a2 = 4 * (n * (n + 1) * (2 * n + 1)) // 6
		print(a1 - a2)


for _ in range(int(input())):
	n = int(input())
	ans = 0
	while n > 0:
		ans += n * n
		n -= 2
	print(ans)


for t in range(int(input())):
	N = int(input())
	sum = 0
	for i in range(1, N + 1, 2):
		sum += (N - i + 1) ** 2
	print(sum)


def count_odd_squares(N):
	count = 0
	for k in range(1, N + 1, 2):
		count += (N - k + 1) * (N - k + 1)
	return count
T = int(input())
for i in range(T):
	N = int(input())
	count = count_odd_squares(N)
	print(count)


b = int(input())
l = []
for nn in range(0, b):
	i = int(input())
	l.append(i)
for vv in l:
	hv = []
	for xxz in range(1, vv + 1):
		if xxz % 2 != 0:
			hv.append(xxz)
	ans = 0
	for innv in hv:
		uurt = vv - (innv - 1)
		ans += uurt ** 2
	print(ans)


for i in range(int(input())):
	x = int(input())
	c = 0
	for i in range(1, x + 1, 2):
		tot = x - i + 1
		c += tot * tot
	print(c)


t = int(input())
while t:
	n = int(input())
	count = 0
	for i in range(1, n + 1, 2):
		count = count + (n + 1 - i) * (n + 1 - i)
	print(count)
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	c = 0
	for i in range(n, 0, -2):
		c += i * i
	print(c)


for i in range(int(input())):
	n = int(input())
	sum = 0
	for j in range(1, n + 1, 2):
		sum = sum + (n - j + 1) * (n - j + 1)
	print(sum)


t = int(input())
while t > 0:
	n = int(input())
	oddlensquares = 0
	for i in range(1, n + 1, 2):
		p = n - (i - 1)
		oddlensquares = oddlensquares + p * p
	print(oddlensquares)
	t = t - 1


def countSquares(n):
	return sum([(n - i + 1) ** 2 for i in range(1, n + 1, 2)])

def __starting_point():
	t = int(input())
	for i in range(t):
		n = int(input())
		print(countSquares(n))
__starting_point()


for _ in range(int(input())):
	n = int(input())
	print(n * (n + 1) * (n + 2) // 6)


from math import *
for i in range(int(input())):
	n = int(input())
	x = int(n * (n + 1) * (n + 2) / 6)
	print(x)


fuck = int(input())
while fuck > 0:
	a = int(input())
	sq = 0
	if a % 2 == 1:
		i = a
		while i >= 0:
			b = (a - i + 1) * (a - i + 1)
			sq += b
			i -= 2
	else:
		i = a - 1
		while i >= 0:
			b = (a - i + 1) * (a - i + 1)
			sq += b
			i -= 2
	print(sq)
	fuck -= 1


for _ in range(int(input())):
	x = int(input())
	print(sum([(x - y) ** 2 for y in range(0, x, 2)]))


t = int(input(''))
l = []
for i in range(t):
	n = int(input(''))
	c = 0
	if n % 2 != 0:
		for j in range(1, n + 1, 2):
			c = c + j ** 2
	else:
		for j in range(2, n + 1, 2):
			c = c + j ** 2
	l.append(c)
for m in l:
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	(n_odd, i) = (0, 1)
	while i <= n:
		if i == 1:
			n_odd += n ** 2
		else:
			n_odd += (n - i + 1) ** 2
		i += 2
	print(n_odd)


t = int(input())
for i in range(t):
	n = int(input())
	if n == 1:
		print(1)
	else:
		sub = 0
		ans = 0
		while n >= sub:
			ans += (n - sub) * (n - sub)
			sub += 2
		print(ans)


for i in range(int(input())):
	n = int(input())
	s = 0
	for i in range(n, 0, -2):
		s = s + i * i
	print(s)


for _ in range(int(input())):
	n = int(input())
	squares = 0
	for i in range(1, n + 1, 2):
		squares += (n - i + 1) ** 2
	print(squares)


for i in range(int(input())):
	x = int(input())
	s = 0
	for i in range(1, x + 1, 2):
		k = x - i + 1
		s += k * k
	print(s)


for i in range(0, int(input())):
	n = int(input())
	t = 0
	for i in range(1, n + 1):
		if i % 2 != 0:
			t = t + (n - (i - 1)) ** 2
		else:
			continue
	print(t)


t = int(input())
for i in range(t):
	n = int(input())
	s = 0
	for i in range(0, n):
		if i % 2 == 0:
			s = s + (n - i) ** 2
	print(s)


testcase_no = int(input())
for testcases in range(testcase_no):
	n = int(input())
	i = n
	sum = 0
	while i >= 0:
		sum += i * i
		i -= 2
	print(sum)


for i in range(int(input())):
	num = int(input())
	out = 0
	if num % 2 == 0:
		for j in range(num + 1):
			if j % 2 == 0:
				out += j ** 2
	else:
		for k in range(num + 1):
			if k % 2 == 1:
				out += k ** 2
	print(out)


for _ in range(int(input())):
	n = int(input())
	s = 0
	s = n * n
	for i in range(3, n + 1, 2):
		x = n - i + 1
		s += x * x
	print(s)


T = int(input())
while T > 0:
	N = int(input())
	sum_ = 0
	if N % 2 == 0:
		for k in range(1, N, 2):
			sum_ += (N - k + 1) ** 2
		print(sum_)
	else:
		for k in range(1, N + 1, 2):
			sum_ += (N - k + 1) ** 2
		print(sum_)
	T -= 1


for i in range(int(input())):
	no_of_side = int(input())
	odd_sq = 0
	for j in range(no_of_side, 0, -2):
		odd_sq += j * j
	print(odd_sq)


import sys
import math
import bisect
from math import factorial as fact

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7

def ncr(n, i):
	num = fact(n)
	den = fact(i) * fact(n - i)
	return num // den
for _ in range(iinput()):
	n = iinput()
	ans = 0
	for i in range(1, n + 1, 2):
		ans += (n - i + 1) * (n - i + 1)
	print(ans)


T = int(input())
for t in range(T):
	ans = 0
	n = int(input())
	for a in range(1, n + 1):
		if a % 2 == 1:
			ans += (n - a + 1) ** 2
	print(ans)


t = int(input())

def odd(n):
	count = 0
	while n >= 0:
		count += n ** 2
		n = n - 2
	return count
for i in range(0, t):
	n = int(input())
	print(odd(n))


for t in range(int(input())):
	n = int(input())
	sum = 0
	while n >= 1:
		sum += n * n
		n -= 2
	print(sum)


t = int(input())
for _ in range(t):
	n = int(input())
	c = n * n
	for i in range(2, n + 1):
		if i % 2 == 1:
			c += (n - i + 1) ** 2
	print(c)


for i in range(int(input())):
	a = int(input())
	b = 0
	while a > 0:
		b = b + a * a
		a = a - 2
	print(b)


for _ in range(int(input())):
	n = int(input())
	sum = 0
	noos = lambda i, n: (n - i + 1) ** 2
	for i in range(1, n + 1, 2):
		sum += noos(i, n)
	print(sum)


for s in [*open(0)][1::1]:
	n = int(s.strip())
	ans = 0
	for i in range(1, n + 1, 2):
		ans += (n - i + 1) ** 2
	print(ans)


x = int(input())
for i in range(x):
	c = 0
	y = int(input())
	while y > 0:
		c = c + y * y
		y = y - 2
	print(c)