Objective: to have one integer per line in the output.
Description: I have to use atexit, io, sys. I am attempting to get better IO performance with Python, then the standard input() and print() functions.
# import libraries for input/ output handling
# on generic level
import atexit, io, sys
# A stream implementation using an in-memory bytes
# buffer. It inherits BufferedIOBase.
buffer = io.BytesIO()
sys.stdout = buffer
# # print via here
@atexit.register
def write():
sys.__stdout__.write(str(buffer.getvalue()))
n=input()
for i in range(int(n)):
r=input()
A, B = [int(c) for c in r.split()]
count_e_i, count_o_i, count_e_j, count_o_j = 0, 0, 0, 0
for i in range(1, A + 1):
if (i) % 2 == 0:
count_e_i += 1
else:
count_o_i += 1
for j in range(1, B + 1):
if (j) % 2 == 0:
count_e_j += 1
else:
count_o_j += 1
sys.stdout.write((str((count_e_i * count_e_j) + (count_o_i * count_o_j))+"\n").encode('utf-8'))
I enter in the following information:
I was expecting the following results:
1
3
12
36