HackerLand University has the following grading policy:

Every student receives a $\textit{grade}$ in the inclusive range from $0$ to $100$.
Any $\textit{grade}$ less than $\boldsymbol{40}$ is a failing grade. 

Sam is a professor at the university and likes to round each student's $\textit{grade}$ according to these rules:

If the difference between the $\textit{grade}$ and the next multiple of $5$ is less than $3$, round $\textit{grade}$ up to the next multiple of $5$.
If the value of $\textit{grade}$ is less than $38$, no rounding occurs as the result will still be a failing grade.

Examples

$grade=84$ round to $85$ (85 - 84 is less than 3)  
$grade=29$ do not round (result is less than 40)  
$grade=57$ do not round (60 - 57 is 3 or higher)   

Given the initial value of $\textit{grade}$ for each of Sam's $n$ students, write code to automate the rounding process.   

Function Description  

Complete the function gradingStudents in the editor below.  

gradingStudents has the following parameter(s):  

int grades[n]:  the grades before rounding  

Returns

int[n]: the grades after rounding as appropriate

Input Format

The first line contains a single integer, $n$, the number of students. 

Each line $\boldsymbol{i}$ of the $n$ subsequent lines contains a single integer, $grades[i]$.

Constraints

$1\leq n\leq60$
$0\leq\textit{grades}[i]\leq100$

Sample Input 0
4
73
67
38
33

Sample Output 0
75
67
40
33

Explanation 0

Student $1$ received a $73$, and the next multiple of $5$ from $73$ is $75$. Since $75-73<3$, the student's grade is rounded to $75$.
Student $2$ received a $67$, and the next multiple of $5$ from $67$ is $70$. Since $70-67=3$, the grade will not be modified and the student's final grade is $67$.
Student $3$ received a $38$, and the next multiple of $5$ from $38$ is $\boldsymbol{40}$. Since $40-38<3$, the student's grade will be rounded to $\boldsymbol{40}$.
Student $4$ received a grade below $33$, so the grade will not be modified and the student's final grade is $33$.

Source: hackerrank | Difficulty: EASY
Tags: Implementation


Solutions:
import sys
n = int(input().strip())
for a0 in range(n):
	x = int(input().strip())
	if x >= 38:
		if x % 5 > 2:
			while x % 5 != 0:
				x += 1
	print(x)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 5 > 2:
		print((grade // 5 + 1) * 5)
	else:
		print(grade)


for _ in range(int(input())):
	m = int(input())
	if m > 37:
		if m % 5 >= 3:
			m += 5 - m % 5
	print(m)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	rem = grade % 5
	if grade < 38:
		print(grade)
	elif rem >= 3:
		print(grade + (5 - rem))
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38 and grade % 5 > 2:
		grade = -(-grade // 5) * 5
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif (grade + 1) % 5 == 0:
		print(grade + 1)
	elif (grade + 2) % 5 == 0:
		print(grade + 2)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
		continue
	if grade % 5 < 3:
		print(grade)
		continue
	print(grade + 5 - grade % 5)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38 or grade % 5 <= 2:
		print(grade)
	else:
		print(grade + (5 - grade % 5))


for _ in range(int(input())):
	g = int(input())
	if g < 38:
		print(g)
	else:
		r = g % 5
		if r > 2:
			g += 5 - r
		print(g)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif 5 - grade % 5 < 3:
		print(grade + 5 - grade % 5)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	else:
		temp = int(grade / 5) + 1
		if temp * 5 - grade < 3:
			print(temp * 5)
		else:
			print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38:
		rem = (grade // 5 + 1) * 5 - grade
		if rem < 3:
			grade += rem
	print(grade)


n = int(input())
for _ in range(n):
	grade = int(input())
	if grade >= 38 and grade % 5 >= 3:
		grade += 5 - grade % 5
	print(grade)


for _ in range(int(input())):
	N = int(input())
	if N < 38:
		print(N)
	elif (N + 2) % 5 == 0:
		print(N + 2)
	elif (N + 1) % 5 == 0:
		print(N + 1)
	else:
		print(N)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38:
		if grade % 5 > 2:
			grade += 5 - grade % 5
	print(grade)


def next_mult(b):
	if b < 38:
		return b
	orig_b = b
	for i in range(2):
		b += 1
		if b % 5 == 0:
			return b
	return orig_b
n = int(input())
grades = []
for i in range(n):
	print(next_mult(int(input())))


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	a = grade % 5
	if grade < 38:
		print(grade)
	elif a >= 3:
		print(grade + 5 - a)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38:
		if grade % 5 > 2:
			grade += 5 - grade % 5
			print(grade)
		else:
			print(grade)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 5 <= 2:
		print(grade)
	else:
		print(grade // 5 * 5 + 5)


import sys

def roundGrade(grade):
	if grade < 38:
		return grade
	roundUp = 5 - grade % 5
	if roundUp < 3:
		return grade + roundUp
	return grade
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	print(roundGrade(grade))


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	k = grade // 5
	n = grade % 5
	if grade >= 38:
		if n >= 3:
			print(5 * (k + 1))
		else:
			print(grade)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	print(int(grade < 38 or (grade >= 38 and grade % 5 in [0, 1, 2])) * grade + int(grade >= 38) * int(grade % 5 in [3, 4]) * ((grade + 5) // 5 * 5))


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	else:
		temp = 5 * (grade // 5 + 1)
		if temp - grade < 3:
			print(temp)
		else:
			print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
		continue
	if grade % 10 >= 3 and grade % 10 <= 5:
		grade = grade // 10 * 10 + 5
	elif grade % 10 >= 8 and grade % 10 <= 9:
		grade = grade // 10 * 10 + 10
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	i = int(input().strip())
	if i % 5 != 0 and i > 37:
		j = i // 5
		k = j * 5 + 5
		if k - i < 3:
			print(k)
		else:
			print(i)
	else:
		print(i)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 5 >= 3:
		print(grade + (5 - grade % 5))
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 10 == 4 or grade % 10 == 9:
		print(grade + 1)
	elif grade % 10 == 3 or grade % 10 == 8:
		print(grade + 2)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
		continue
	diff = grade % 5
	multiple = grade // 5
	if diff > 2:
		print((multiple + 1) * 5)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade > 35:
		nextGrade = grade - grade % 5 + 5
		if nextGrade - grade < 3:
			grade = nextGrade
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade > 37 and grade % 5 > 2:
		grade += 5 - grade % 5
	print(grade)


n = int(input())
for i in range(0, n):
	marks = int(input())
	if marks >= 38:
		div = marks // 5
		if (div + 1) * 5 - marks < 3:
			print((div + 1) * 5)
		else:
			print(marks)
	else:
		print(marks)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38:
		if (grade // 5 + 1) * 5 - grade < 3:
			grade = 5 * (grade // 5 + 1)
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	final = grade
	for i in range(grade, grade + 3):
		if grade < 38:
			final = grade
			break
		elif i % 5 == 0:
			final = i
	print(final)


import sys

def round_grade(grade):
	if grade < 38:
		return grade
	next_num = grade + (5 - grade % 5)
	if next_num - grade < 3:
		return next_num
	return grade
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	print(round_grade(grade))


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	else:
		t = grade // 5
		if (t + 1) * 5 - grade < 3:
			print((t + 1) * 5)
		else:
			print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
		continue
	if grade % 5 < 3:
		print(grade)
	else:
		print(grade + 5 - grade % 5)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 5 != 0:
		if (grade + 1) % 5 == 0:
			print(grade + 1)
		elif (grade + 2) % 5 == 0:
			print(grade + 2)
		else:
			print(grade)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38:
		if grade % 5 >= 3:
			print(grade + (5 - grade % 5))
		else:
			print(grade)
	else:
		print(grade)


import sys

def roundGrade(g):
	resto = g % 5
	if g < 38:
		return g
	elif resto >= 3:
		return g - resto + 5
	else:
		return g
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	print(roundGrade(grade))


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
		continue
	elif grade % 5 >= 3:
		print(grade - grade % 5 + 5)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade % 5 > 2 and grade >= 38:
		grade += 5 - grade % 5
	print(grade)


t = int(input())
for i in range(t):
	grade = int(input())
	if grade < 38:
		print(grade)
	else:
		if grade % 5 == 4:
			grade += 1
		elif grade % 5 == 3:
			grade += 2
		print(grade)


from sys import stdin
from math import ceil
for student_id in range(int(stdin.readline())):
	grade = int(stdin.readline())
	if grade < 38:
		print(grade)
	elif ceil(grade / 5) * 5 - grade < 3:
		print(ceil(grade / 5) * 5)
	else:
		print(grade)


tc = int(input())
for _ in range(tc):
	n = int(input())
	first = n
	ret = 0
	while n % 5 != 0:
		ret += 1
		n += 1
	if ret < 3 and n >= 40:
		print(n)
	else:
		print(first)


import sys
for i in range(int(input())):
	n = int(input().strip())
	if n < 38:
		print(n)
	else:
		nex = (int(n / 5) + 1) * 5
		if nex - n < 3:
			print(nex)
		else:
			print(n)


for _ in range(int(input())):
	grade = int(input())
	if grade % 5 >= 3 and grade >= 38:
		print(grade + 5 - grade % 5)
	else:
		print(grade)


n = int(input())
for i in range(n):
	s = int(input())
	if s < 38:
		print(s)
	elif s % 5 > 2:
		print(s + (5 - s % 5))
	else:
		print(s)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	x = 0
	if grade < 38:
		x = grade
	elif (grade + 1) % 5 == 0:
		x = grade + 1
	elif (grade + 2) % 5 == 0:
		x = grade + 2
	else:
		x = grade
	print(x)


import sys
import math
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	x = math.ceil(grade / 5) * 5
	if grade < 38:
		print(grade)
	elif math.ceil(grade / 5) * 5 - grade < 3:
		print(x)
	else:
		print(grade)


n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38 or grade % 5 == 0:
		print(grade)
		continue
	diff = grade % 5
	if diff > 2:
		print(grade + (5 - diff))
	else:
		print(grade)


n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 5 >= 3:
		print((grade // 5 + 1) * 5)
	else:
		print(grade)


import sys
import math

def grade_student(numb):
	if numb < 38:
		return numb
	else:
		lower_num = numb % 5
		if lower_num > 2:
			return 5 * math.ceil(numb / 5)
		else:
			return numb
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	print(grade_student(grade))


t = int(input())
while t > 0:
	n = int(input())
	if n < 38:
		print(n)
	elif n % 5 < 3:
		print(n)
	else:
		n += 5 - n % 5
		print(n)
	t -= 1


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38 or grade % 5 <= 2:
		print(grade)
	else:
		print(grade + 5 - grade % 5)


import sys
import math

def round(grade):
	if grade < 38:
		return grade
	newGrade = math.ceil(grade * 2 / 10) * 5
	if newGrade - grade < 3:
		return newGrade
	else:
		return grade
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	print(round(grade))


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	else:
		m = int(grade / 5)
		n = (m + 1) * 5
		if n - grade < 3:
			print(n)
		else:
			print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38:
		if grade % 5 > 2:
			grade += 5 - grade % 5
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 5 > 2:
		grade = grade // 5
		grade += 1
		grade *= 5
		print(grade)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 5 >= 3:
		print(grade + (5 - grade % 5))
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38 and grade % 5 > 2:
		grade = (grade // 5 + 1) * 5
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	a = grade // 5
	b = a * 5 + 5
	c = b - grade
	if c < 3 and grade >= 38:
		print(b)
	else:
		print(grade)


import sys
n = int(input().strip())
for i in range(n):
	grade = int(input().strip())
	if grade < 37:
		print(grade)
	elif grade % 5 >= 3:
		grade += 5 - grade % 5
		print(grade)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38:
		diff = 5 - grade % 5
		if diff < 3:
			grade += diff
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	else:
		n = grade // 5
		if (n + 1) * 5 - grade < 3:
			print((n + 1) * 5)
		else:
			print(grade)


import sys

def round_grade(grade):
	if grade < 38:
		return grade
	(whole, remainder) = divmod(grade, 5)
	if remainder < 3:
		return grade
	return (whole + 1) * 5
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	print(round_grade(grade))


import sys

def round_grade(grade):
	if grade < 38:
		return grade
	elif grade % 5 == 0:
		return grade
	elif (grade + 2) % 5 == 0:
		return grade + 2
	elif (grade + 1) % 5 == 0:
		return grade + 1
	else:
		return grade
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	print(round_grade(grade))


import sys
n = int(input().strip())

def get_grade(n):
	reminder = n % 5
	new_num = 0
	if reminder >= 3:
		new_num = n + (5 - reminder)
	if new_num < 40:
		return n
	else:
		return new_num
for a0 in range(n):
	grade = int(input().strip())
	print(get_grade(grade))


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38 or grade % 5 < 3:
		print(grade)
	else:
		print(grade + (5 - grade % 5))


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade > 37:
		if grade % 5 != 0 and (grade // 5 + 1) * 5 - grade < 3:
			grade = (grade // 5 + 1) * 5
	print(grade)


import sys

def myround(x, base=5):
	return int(base * round(float(x) / base))
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38:
		num = myround(grade)
		check = num - grade
		if check > 0 and check < 3:
			print(num)
		else:
			print(grade)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade % 5 > 2:
		grade2 = grade + (5 - grade % 5)
		if grade2 < 40:
			print(grade)
		else:
			print(grade2)
	else:
		print(grade)


import sys
n = int(input().strip())
for i in range(n):
	grade = int(input())
	if grade >= 38:
		m = grade % 5
		new = grade - m + 5
		k = new - grade
		if k < 3:
			print(new)
		else:
			print(grade)
	else:
		print(grade)


import sys

def next_multiple(num):
	multiple = num // 10 * 10
	multiple += 5
	if multiple > 100:
		return 100
	elif num > multiple:
		return multiple + 5
	else:
		return multiple
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif next_multiple(grade) - grade < 3:
		print(next_multiple(grade))
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	ans = (grade + 2) // 5 * 5
	if grade < 38 or ans < grade:
		ans = grade
	print(ans)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	else:
		(a, b) = divmod(grade, 10)
		if b == 3 or b == 4:
			print(10 * a + 5)
		elif b == 8 or b == 9:
			print(10 * (a + 1))
		else:
			print(grade)


import sys
mlist = []
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	mlist.append(grade)
for x in range(n):
	if mlist[x] >= 38:
		for y in range(1, 3):
			if (mlist[x] + y) % 5 == 0:
				mlist[x] = mlist[x] + y
for x in range(n):
	print(mlist[x])


import sys
import math
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	nextMultiple = (math.floor(grade / 5) + 1) * 5
	if grade >= 38 and nextMultiple - grade < 3:
		print(nextMultiple)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade % 5 >= 3:
		x = (int(grade / 5) + 1) * 5
		if x >= 40:
			grade = x
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	rem = grade % 5
	if grade < 38 or rem == 0:
		print(grade)
	elif rem > 2:
		print(grade + 5 - rem)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if (grade // 5 + 1) * 5 - grade < 3 and grade >= 38:
		grade = (grade // 5 + 1) * 5
	print(grade)


N = int(input().strip())
for g in range(0, N):
	grade = int(input().strip())
	if grade < 38 or grade % 5 in [0, 1, 2]:
		print(grade)
	else:
		print(grade + 5 - grade % 5)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade >= 38 and 5 * (1 + grade // 5) - grade < 3:
		grade = 5 * (1 + grade // 5)
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	x = grade % 5
	y = grade / 5
	if grade < 38:
		print(grade)
	elif x >= 3:
		print(grade + (5 - x))
	else:
		print(grade)


import math
import sys
n = int(input().strip())
grade = []
for a0 in range(n):
	grade.append(int(input()))
for i in grade:
	if i < 38:
		print(i)
	elif math.ceil(i / 5) * 5 - i >= 3:
		print(i)
	elif math.ceil(i / 5) * 5 - i < 3:
		print(math.ceil(i / 5) * 5)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif int(grade / 5 + 1) * 5 - grade < 3:
		print(int(grade / 5 + 1) * 5)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	else:
		x = int(grade / 5)
		x += 1
		p = x * 5 - grade
		if p < 3:
			print(x * 5)
		else:
			print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 5 == 0:
		print(grade)
	elif (grade // 5 + 1) * 5 - grade < 3:
		print((grade // 5 + 1) * 5)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	elif grade % 5 > 2:
		print(grade - grade % 5 + 5)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	next_number = (grade // 5 + 1) * 5
	if grade < 38:
		print(grade)
	elif next_number - grade < 3:
		print(next_number)
	else:
		print(grade)


n = int(input())
while n > 0:
	n -= 1
	x = int(input())
	if x < 38:
		print(x)
	elif x % 5 == 3 or x % 5 == 4:
		print((x // 5 + 1) * 5)
	else:
		print(x)


import sys
n = int(input().strip())
for _ in range(n):
	grade = int(input().strip())
	if grade % 5 != 0 and grade >= 38:
		diff = (grade // 5 + 1) * 5 - grade
		if diff < 3:
			print(grade + diff)
		else:
			print(grade)
	else:
		print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
		continue
	less = grade // 5 * 5
	if grade - less > 2:
		grade = less + 5
	print(grade)


import sys
import math
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	rounded = int(math.ceil(grade / 5)) * 5
	if grade < 38:
		print(grade)
	elif rounded - grade < 3:
		print(rounded)
	else:
		print(grade)


import sys

def comupute_grade(grade):
	if grade < 38:
		return grade
	else:
		difference = 5 - grade % 5
		if difference < 3:
			return grade + difference
		else:
			return grade
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	print(comupute_grade(grade))


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade > 37:
		ex = grade % 5
		if ex > 2:
			grade += 5 - ex
	print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 37:
		print(grade)
	elif grade % 5 > 2:
		print((grade // 5 + 1) * 5)
	else:
		print(grade)


import sys
n = int(input().strip())
for _ in range(n):
	grade = int(input().strip())
	if grade < 38:
		ans = grade
	elif 5 - grade % 5 < 3:
		ans = grade + (5 - grade % 5)
	else:
		ans = grade
	print(ans)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade < 38:
		print(grade)
	else:
		quotient = int(grade / 5)
		rem = int(grade % 5)
		if rem > 2:
			print((quotient + 1) * 5)
		else:
			print(grade)


def roundof(num):
	while num % 5 != 0:
		num += 1
	return num
students = int(input())
for _ in range(students):
	grade = int(input())
	if grade < 38:
		print(grade)
	else:
		val = roundof(grade)
		if val - grade < 3:
			print(val)
		elif val - grade >= 3:
			print(grade)


import sys
n = int(input().strip())
for a0 in range(n):
	grade = int(input().strip())
	if grade % 5 > 2 and grade > 35:
		grade = (int(grade / 5) + 1) * 5
	print(grade)