Faizal is very sad after finding out that he is responsible for Sardar's death. He tries to drown his sorrows in alcohol and gets very drunk. Now he wants to return home but is unable to walk straight. For every 3 steps forward, he ends up walking one step backward.

Formally, in the 1^{st} second he moves 3 steps forward, in the 2^{nd} second he moves 1 step backwards, in the 3^{rd} second he moves 3 steps forward, in 4^{th} second 1 step backwards, and so on.

How far from his initial position will Faizal be after k seconds have passed?
Assume that Faizal's initial position is 0.

------ Input Format ------ 

- The first line of input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains a single integer k, the number of seconds after which Faizal's position is to be calculated. 

------ Output Format ------ 

- For each test case, output a single line containing one integer - Faizal's position after k seconds.

------ Constraints ------ 

$1 ≤ T ≤ 100000$
$0 ≤ k ≤ 100000$
- The sum of $k$ over all test cases does not exceed $1000000$

----- Sample Input 1 ------ 
3
5
11
23

----- Sample Output 1 ------ 
7
13
25

----- explanation 1 ------ 
1st Test Case
- Faizal walks $3$ steps forward in the $1^{st}$ second, ending up at $3$
- Faizal walks $1$ step backward in the $2^{nd}$ second, ending up at $2$
- Faizal walks $3$ steps forward in the $3^{rd}$ second, ending up at $5$
- Faizal walks $1$ step backward in the $4^{th}$ second, ending up at $4$
- Faizal walks $3$ steps forward in the $5^{th}$ second, ending up at $7$

Difficulty: EASY
Tags: Complete search

Constructive algorithms

Implementation

Ad-hoc
Skill types: Complete search

Starter code:

Solutions:
for i in range(int(input())):
	k = int(input())
	c = 0
	for i in range(k):
		if i % 2 != 0:
			c -= 1
		else:
			c += 3
	print(c)


t = int(input())
for i in range(t):
	k = int(input())
	if k % 2 == 0:
		print(k // 2 * 2)
	else:
		print(k // 2 * 2 + 3)


for i in range(int(input())):
	a = int(input())
	c = 0
	d = 0
	for i in range(1, a + 1, 2):
		c += 3
	for i in range(2, a + 1, 2):
		d -= 1
	print(c + d)


for i in range(int(input())):
	n = int(input())
	if n % 2 != 0:
		n += 2
		print(n)
	else:
		print(n)


t = int(input())
for _ in range(t):
	k = int(input())
	if k % 2 == 0:
		print(k)
	else:
		print(k + 2)


t = int(input())
for i in range(t):
	x = int(input())
	a = x // 2
	b = a * 2
	if x % 2 == 1:
		b = b + 3
	print(b)


for t in range(int(input())):
	co = 0
	for i in range(int(input())):
		if i % 2 == 0:
			co += 3
		else:
			co -= 1
	print(co)


for _ in range(int(input())):
	k = int(input())
	count = 0
	for i in range(k):
		if i % 2 == 0:
			count += 3
		else:
			count -= 1
	print(count)


T = int(input())
for tc in range(T):
	k = int(input())
	r = k % 2
	if r == 0:
		print(k)
	else:
		print(k + 2)


t = int(input())
while t > 0:
	k = int(input())
	count = 0
	for i in range(1, k + 1):
		if i % 2 != 0:
			count += 3
		else:
			count -= 1
	print(count)
	t = t - 1


t = int(input())
for i in range(t):
	k = int(input())
	position = 0
	for j in range(1, k + 1):
		if j % 2 == 1:
			position += 3
		else:
			position -= 1
	print(position)


for i in range(int(input())):
	m = 0
	for h in range(int(input())):
		if h % 2 == 0:
			m += 3
		else:
			m -= 1
	print(m)


for i in range(int(input())):
	k = int(input())
	ini = 0
	v = 0
	for i in range(1, k + 1):
		if i % 2 == 0:
			v -= 1
		else:
			v += 3
	print(v)


for _ in range(int(input())):
	a = int(input())
	b = 0
	for x in range(a):
		if x % 2 == 0:
			b += 3
		else:
			b -= 1
	print(b)


for i in range(int(input())):
	t = int(input())
	d = 0
	for j in range(t):
		if j % 2 == 0:
			d += 3
		else:
			d -= 1
	print(d)


n = int(input())
for i in range(n):
	a = int(input())
	count = 0
	while a:
		if a % 2 != 0:
			count = count + 3
		else:
			count = count - 1
		a = a - 1
	print(count)


t = int(input())
for i in range(t):
	x = int(input())
	c = x // 2
	d = c * 2
	if x % 2 == 1:
		d = d + 3
	print(d)


t = int(input())
for t in range(t):
	a = int(input())
	if a % 2 == 0:
		print(a)
	else:
		b = int(a / 2)
		print(3 + 2 * b)


t = int(input())
for i in range(t):
	x = int(input())
	nve = x // 2
	value1 = -1 * nve
	pve = x - nve
	value2 = 3 * pve
	total = value1 + value2
	print(total)


for i in range(int(input())):
	k = int(input())
	sum = 0
	for j in range(1, k + 1):
		if j % 2 == 1:
			sum += 3
		else:
			sum = sum - 1
	print(sum)


T = int(input())
while T > 0:
	k = int(input())
	if k % 2 == 0:
		print(k)
	else:
		print(k + 2)
	T = T - 1


n = int(input())
for i in range(n):
	a = int(input())
	c = 0
	for j in range(1, a + 1):
		if j % 2 != 0:
			c = c + 3
		else:
			c = c - 1
	print(c)


for i in range(int(input())):
	x = int(input())
	stp = 0
	for i in range(x):
		if i % 2 == 0:
			stp += 3
		else:
			stp -= 1
	print(stp)
	stp = 0


t = int(input())
for i in range(t):
	k = int(input())
	e = k // 2
	od = k - e
	s = od * 3 - e
	print(s)


for i in range(int(input())):
	sec = 0
	for j in range(int(input())):
		if j % 2 == 0:
			sec += 3
		else:
			sec -= 1
	print(sec)


for i in range(int(input())):
	x = int(input())
	step = 0
	for j in range(x):
		if j % 2 == 0:
			step += 3
		else:
			step -= 1
	print(step)


for i in range(int(input())):
	a = int(input())
	count = 0
	add = 3
	sub = 1
	j = 1
	for j in range(a):
		if j % 2 == 0:
			count += add
		elif j % 2 != 0:
			count -= sub
	print(count)


t = int(input())
for i in range(t):
	c = 0
	a = int(input())
	for i in range(a):
		if i % 2 == 0:
			c += 3
		else:
			c -= 1
	print(c)


for _ in range(int(input())):
	k = int(input())
	even = k // 2
	print((k - even) * 3 - even)


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


T = int(input())
for _ in range(T):
	k = int(input())
	pos = 0
	for i in range(0, k):
		if i % 2 == 0:
			pos += 3
		elif i % 2 != 0:
			pos -= 1
	print(pos)


d = int(input())
for i in range(d):
	w = int(input())
	a = w // 2
	r = a * 2
	if w % 2 == 1:
		r = r + 3
	print(r)


t = int(input())
for t in range(t):
	x = int(input())
	if x % 2 == 0:
		print(x)
	else:
		print(x + 2)


t = int(input())
for i in range(0, t):
	x = int(input())
	a = 0
	for j in range(0, x):
		if j % 2 == 0:
			a += 3
		else:
			a -= 1
	print(a)


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


t = int(input())
for i in range(t):
	x = int(input())
	cur_sec = 1
	steps = 0
	while cur_sec <= x:
		if cur_sec % 2 != 0:
			steps += 3
		elif cur_sec % 2 == 0:
			steps -= 1
		cur_sec += 1
	print(steps)


def code():
	cases = int(input())
	for _ in range(cases):
		k = int(input())
		cur_sec = 1
		steps = 0
		while cur_sec <= k:
			if cur_sec % 2 != 0:
				steps += 3
			elif cur_sec % 2 == 0:
				steps -= 1
			cur_sec += 1
		print(steps)
code()


t = int(input())
for i in range(t):
	k = int(input())
	a = k // 2
	b = (k - a) * 3
	ans = b - a
	print(ans)


x = int(input())
for i in range(x):
	n = int(input())
	if n % 2 == 0:
		a = n // 2
		b = n - a
		print(a * 3 - b)
	else:
		a = n // 2 + 1
		b = n - a
		print(a * 3 - b)


for _ in range(int(input())):
	a = int(input())
	if a % 2 == 0:
		print(a)
	else:
		print(a + 2)


t = int(input())
while t > 0:
	k = int(input())
	if k % 2 == 0:
		print(k)
	else:
		print(k + 2)
	t = t - 1


T = int(input())
for i in range(T):
	walks = int(input())
	ans = 0
	for i in range(1, walks + 1, 1):
		if i % 2 == 0:
			ans = ans - 1
		else:
			ans += 3
	print(ans)


t = int(input())
for _ in range(t):
	x = int(input())
	res = 0
	forward = True
	while x > 0:
		if forward:
			res += 3
			forward = False
		else:
			res -= 1
			forward = True
		x = x - 1
	print(res)


T = int(input())
for _ in range(T):
	k = int(input())
	ans = 0
	for i in range(k):
		if i % 2 == 0:
			ans += 3
		else:
			ans -= 1
	print(ans)


T = int(input())
for i in range(T):
	N = int(input())
	n = 0
	for i in range(N):
		if i % 2 == 0:
			n += 3
		else:
			n -= 1
	print(n)


for _ in range(int(input())):
	n = int(input())
	if n % 2 != 0:
		print(n // 2 * 2 + 3)
	else:
		print(n)