Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ------------------- fast io --------------------
- import os
- import sys
- from io import BytesIO, IOBase
- class FastIO(IOBase):
- newlines = 0
- def __init__(self, file):
- self._fd = file.fileno()
- self.buffer = BytesIO()
- self.writable = "x" in file.mode or "r" not in file.mode
- self.write = self.buffer.write if self.writable else None
- def read(self):
- while True:
- b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))
- if not b:
- break
- ptr = self.buffer.tell()
- self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
- self.newlines = 0
- return self.buffer.read()
- def readline(self):
- while self.newlines == 0:
- b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))
- self.newlines = b.count(b"\n") + (not b)
- ptr = self.buffer.tell()
- self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
- self.newlines -= 1
- return self.buffer.readline()
- def flush(self):
- if self.writable:
- os.write(self._fd, self.buffer.getvalue())
- self.buffer.truncate(0), self.buffer.seek(0)
- class IOWrapper(IOBase):
- def __init__(self, file):
- self.buffer = FastIO(file)
- self.flush = self.buffer.flush
- self.writable = self.buffer.writable
- self.write = lambda s: self.buffer.write(s.encode("ascii"))
- self.read = lambda: self.buffer.read().decode("ascii")
- self.readline = lambda: self.buffer.readline().decode("ascii")
- sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
- input = lambda: sys.stdin.readline().rstrip("\r\n")
- # ------------------- fast io --------------------
- from math import ceil
- def prod(a, mod=10 ** 9 + 7):
- ans = 1
- for each in a:
- ans = (ans * each) % mod
- return ans
- def gcd(x, y):
- while y:
- x, y = y, x % y
- return x
- def lcm(a, b): return a * b // gcd(a, b)
- def binary(x, length=16):
- y = bin(x)[2:]
- return y if len(y) >= length else "0" * (length - len(y)) + y
- from bisect import bisect_left, bisect_right
- class Result:
- def __init__(self, index, value):
- self.index = index
- self.value = value
- class BinarySearch:
- def __init__(self):
- pass
- @staticmethod
- def greater_than(num: int, func, size: int = 1):
- """Searches for smallest element greater than num!"""
- if isinstance(func, list):
- index = bisect_right(func, num)
- if index == len(func):
- return Result(None, None)
- else:
- return Result(index, func[index])
- else:
- alpha, omega = 0, size - 1
- if func(omega) <= num:
- return Result(None, None)
- while alpha < omega:
- if func(alpha) > num:
- return Result(alpha, func(alpha))
- if omega == alpha + 1:
- return Result(omega, func(omega))
- mid = (alpha + omega) // 2
- if func(mid) > num:
- omega = mid
- else:
- alpha = mid
- @staticmethod
- def less_than(num: int, func, size: int = 1):
- """Searches for largest element less than num!"""
- if isinstance(func, list):
- index = bisect_left(func, num) - 1
- if index == -1:
- return Result(None, None)
- else:
- return Result(index, func[index])
- else:
- alpha, omega = 0, size - 1
- if func(alpha) >= num:
- return Result(None, None)
- while alpha < omega:
- if func(omega) < num:
- return Result(omega, func(omega))
- if omega == alpha + 1:
- return Result(alpha, func(alpha))
- mid = (alpha + omega) // 2
- if func(mid) < num:
- alpha = mid
- else:
- omega = mid
- bs = BinarySearch()
- ints = lambda: list(map(int, input().split()))
- for _ in range(int(input())):
- d = [2, 22]
- # for j in range(10000):
- # d.append(d[-1]//10*10*10+2)
- # su = 0
- # for j in range(len(d)):
- # su += d[j]
- # print(j+1, su%100000)
- n, = ints()
- if not n%2:
- if n >= 2228:
- print((n-2228)//2+4)
- elif n==2222:
- print(6)
- elif n==2224:
- print(10)
- elif n==2226:
- print(20)
- else:
- print(n//2+4390)
- else:
- if n > 2222:
- print((n-2223)*5+5)
- else:
- print(n*5+5+38885)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement