The positive odd numbers are sorted in ascending order as $1,3,5,7,9,11,13,15,17,19\ldots$, and grouped as $(1),(3,5),(7,9,11),(13,15,17,19),...$ and so on.

Thus, the first group is $\left(1\right)$, the second group is $(3,5)$, the third group is $(7,9,11)$, etc. In general, the $k^{\text{th}}$ group contains the next $\boldsymbol{\mbox{k}}$ elements of the sequence. 

Given $\boldsymbol{\mbox{k}}$, find the sum of the elements of the $k^{\text{th}}$ group. For example, for $k=3$, the answer is $27$:

Complete the function sumOfGroup with input integer $\boldsymbol{\mbox{k}}$.  Return the sum of the elements of the $\boldsymbol{\mbox{k}}$th group.

Constraints

$1\leq k\leq10^6$  

Subtasks  

For $50\%$ of the maximum score, $k\leq10^3$  

Sample Input

$k=3$

Sample Output

$27$

Explanation

We have $k=3$. The $3$rd group is $(7,9,11)$ and the sum of its elements is $7+9+11=27$.

Difficulty: EASY
Tags: Matrices

Starter code:

Solutions:
import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return pow(k, 3)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	el = k * (k - 1) + 1
	res = k * el
	res += k * (k - 1)
	return res
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys
k = int(input().strip())
print(k ** 3)


print(int(input()) ** 3)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	start = k * (k - 1) // 2 + 1
	start = start * 2 - 1
	end = start + 2 * (k - 1)
	b = (end + 1) // 2
	a = (start - 1) // 2
	return b ** 2 - a ** 2
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	elements_covered = (k - 1) * k // 2
	total_elements = k * (k + 1) // 2
	return total_elements ** 2 - elements_covered ** 2
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	n = k * (k + 1) // 2 * 2 - 1
	s = 0
	for i in range(0, k):
		s = s + (n - 2 * i)
	return s
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	temp = k * (k - 1) // 2
	return (2 * temp + 1) * k + (k - 1) * (k - 1) + (k - 1)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	sum = 0
	x = k * (k - 1) + 1
	for i in range(k):
		sum = sum + x
		x = x + 2
	return sum
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	if k == 1:
		return 1
	p = int(k * (k - 1) / 2)
	pp = 2 * p + 1
	s = 0
	for i in range(k):
		s += pp + 2 * i
	return int(s)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	a = k ** 2 - k + 1
	l = [a]
	for _ in range(k - 1):
		l.append(a + 2)
		a = a + 2
	return sum(l)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	n1 = k * (k - 1) // 2
	n2 = k * (k + 1) // 2
	sum1 = n1 * (2 + (n1 - 1) * 2) // 2
	sum2 = n2 * (2 + (n2 - 1) * 2) // 2
	return sum2 - sum1
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def nth_odd(n):
	return 2 * n + 1

def sum_k(k):
	total = 0
	for i in range(k, -1, -1):
		total += i
	return total

def sumOfGroup(k):
	total = 0
	k_sum = sum_k(k - 1)
	for i in range(k_sum, k_sum + k):
		total += nth_odd(i)
	return total
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


n = int(input())
print(n * n * n)


import sys

def sumOfGroup(k):
	n = k * (k - 1) // 2
	return (2 * n + k) * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	b = k * (k + 1) // 2
	a = k * (k - 1) // 2
	return b * b - a * a
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


k = int(input())
start = k * k - k + 1
ans = 0
for i in range(k):
	ans += start
	start += 2
print(ans)


import sys

def sumOfGroup(k):
	start = int(k * (k - 1) / 2) + 1
	end = int(k * (k + 1) / 2)
	(start_val, end_val) = (2 * start - 1, 2 * end - 1)
	return int((start_val + end_val) / 2) * (end - start + 1)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	n = k * (k + 1)
	n -= 1
	sum = 0
	while k > 0:
		sum += n
		n -= 2
		k -= 1
	return sum
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


k = int(input())
n = k - 1
st = n * (n + 1) // 2 + 1
nost = 1 + (st - 1) * 2
ans = 0
while k > 0:
	k -= 1
	ans += nost
	nost += 2
print(ans)


import sys

def sumOfGroup(n):
	s = 0
	x = n
	n = n * (n + 1) // 2
	for i in range(2 * (n - x) + 1, 2 * n + 1, 2):
		s += i
	return s
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	index = (k - 1) * k // 2
	index += 1
	su = 0
	for i in range(k):
		temp = (index - 1) * 2 + 1
		su += (index - 1) * 2 + 1
		index += 1
	return su
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	start = k ** 2 - k + 1
	sum = start
	temp = start
	while k > 1:
		temp += 2
		k -= 1
		sum += temp
	return sum
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys
a = int(input())
print(a * a * a)


a = int(input())
print(a ** 3)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	SumofK = k * (k - 1) // 2
	count = 0
	for i in range(k):
		count = count + 2 * (SumofK + i) + 1
	return count
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


n = int(input().strip())
print(n * (n * (n - 1) + 1 + n - 1))


k = int(input())
a = 1 + k * (k - 1)
la = a + (k - 1) * 2
s = k * (a + la) // 2
print(s)


k = int(input())
n = 1 + k * (k - 1)
res = n * k + k * (k - 1)
print(res)


import sys

def sumOfGroup(k):
	first = (k - 1) * k + 1
	last = first + k * 2
	return sum(range(first, last, 2))
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return pow(k, 3)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	k -= 1
	x = k * (k + 1) // 2
	y = 2 * (x + 1) - 1
	r = 0
	for i in range(k + 1):
		r += y
		y += 2
	return r
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	num = (k - 1) * k // 2
	a = 2 * num
	a += 1
	return k * (a + k - 1)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def grp_last_idx(k):
	return (k + 1) * k // 2

def grp_sum_to_last(k):
	n = grp_last_idx(k)
	return n * n

def sumOfGroup(k):
	return grp_sum_to_last(k) - grp_sum_to_last(k - 1)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	start = k ** 2 - k + 1
	res = k * (start + k - 1)
	return res
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


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


import sys

def sumOfGroup(k):
	t = int(0.5 * k * (k + 1))
	return sum([2 * x + 1 for x in list(range(t - k, t))])
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


l = []
k = int(input())
print(k ** 3)


def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	n = k * (k - 1) // 2
	n = 2 * n + 1
	res = 0
	for i in range(k):
		res += n
		n += 2
	return res
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


k = int(input().strip())
print(k ** 3)


import sys

def sumOfGroup(k):
	n = k * (k - 1) // 2
	start = 2 * n + 1
	s = start
	for i in range(k - 1):
		start += 2
		s += start
	return s
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	res = k * (k + 1) // 2
	ans = 0
	start = res * 2 + 1
	for i in range(k + 1):
		ans += start
		start += 2
	return ans
k = int(input().strip())
answer = sumOfGroup(k - 1)
print(answer)


import sys

def sumOfGroup(k):
	s = 0
	for i in range(k * (k - 1) + 1, k * (k + 1), 2):
		s += i
	return s
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	low = sum(range(k))
	high = low + k
	h = high * 2 - 1
	l = low * 2 - 1
	return sum([i for i in range(h, l, -2)])
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	fi = k - 1
	f = fi * (fi + 1) // 2 * 2 + 1
	return f * k + 2 * fi * (fi + 1) // 2
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	s = 0
	for i in range((k - 1) * k + 1, (k - 1) * k + (2 * k + 1), 2):
		s += i
	return s
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	start = (k - 1) * k // 2
	end = k * (k + 1) // 2
	return pow(end, 2) - pow(start, 2)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	first = k * (k - 1) + 1
	sum = 0
	i = 0
	while i < k:
		sum += first
		first += 2
		i += 1
	return sum
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumFrom1ToN(n):
	return n * (n + 1) // 2

def sumOfGroup(k):
	start = (k - 1) * k + 1
	end = start + 2 * k
	s = 0
	for i in range(start, end, 2):
		s += i
	return s
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	n = 0
	s = 0
	for i in range(0, k):
		n += i
	n += 1
	for i in range(n, n + k):
		s += 2 * i - 1
	return s
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	l = k * (k - 1) + 1
	return k * (2 * l + (k - 1) * 2) // 2
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	i = k * (k - 1) // 2
	o1 = 1 + 2 * i
	o2 = o1 + 2 * (k - 1)
	sum = k * (o1 + o2) // 2
	return int(sum)
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


k = int(input())
a = k * (k - 1) + 1
d = 2
n = k
print(n * (2 * a + (n - 1) * d) // 2)


import sys

def sumOfGroup(k):
	return -(k * (k - 1) // 2) ** 2 + (k * (k + 1) // 2) ** 2
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	su = 0
	final = 0
	for i in range(1, k + 1):
		su += i
	for n in range(su - k + 1, su + 1):
		final += 2 * n - 1
	return final
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	k1 = 1
	for i in range(0, k):
		k1 += i
	sum_k = 0
	for i in range(0, k):
		sum_k += 2 * (k1 + i) - 1
	return sum_k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	k = k - 1
	sum_ = k * (k + 1) // 2
	odd1 = 2 * (sum_ + 1) - 1
	odd2 = 2 * (sum_ + k + 1) - 1
	result = sum(range(odd1, odd2 + 1, 2))
	return result
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	a = k * (k - 1) // 2
	b = k * (k + 1) // 2
	a = a * a
	b = b * b
	return b - a
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	startOdd = 1
	for i in range(2, k + 1):
		startOdd += (i - 1) * 2
	sum = 0
	currentOdd = startOdd
	for i in range(k):
		sum += currentOdd
		currentOdd += 2
	return sum
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	nb_elements = k * (k + 1) // 2
	res = 0
	for i in range(1, k + 1):
		res += (nb_elements - i) * 2
		res += 1
	return res
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


print(int(input()) ** 3)


import sys

def sumOfGroup(k):
	return k ** 2 * (k + 1) ** 2 // 4 - k ** 2 * (k - 1) ** 2 // 4
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys
k = int(input().strip())
print(k * k * k)


import sys

def sumOfGroup(k):
	before_kth_grp = (k - 1) * k // 2
	start = 2 * before_kth_grp + 1
	end = start + 2 * (k - 1)
	return (start + end) // 2 * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	s = 0
	a = k * (k - 1) + 1
	for i in range(0, 2 * k, 2):
		s = s + (a + i)
	return s
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)


import sys

def sumOfGroup(k):
	return k * k * k
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)