import itertools as it
import numpy as np
t = int(input())
while t:
n = bin(int(input()))
n = n[2:]
z = 0; o = 0
ans = 0
for i in n:
if i == “1”:
ans += 3int(o)
ans += int(z)
o += 1
else:
ans += 2int(o)
z += 1
print(ans)
t -= 1

This is my submission for the problem Bit Pair Sum. But it gave me NZEC for some unknown reason.
I’m new to python so please help me find what’s wrong. Thank you in advance!!

Something is definitely wrong with the testcases. There is only one accepted submission in Python, which uses try-except to end the program when it encounters an error ¯\_(ツ)_/¯

Numpy is allowed in competitive programming. This is not the problem of numpy, there is a problem with test case that’s why all we were getting run time error.

As far as I know, numpy and scipy are allowed, but I have never felt the need to use them and can’t think of many such scenarios either… perhaps if you need to do FFT or for linear algrebra they can be useful.