NZEC in bit pair sum | codewhizz 1.0

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 += 2
int(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 ¯\_(ツ)_/¯

1 Like

I never knew numpy was allowed in competitive programming. Have you used it before or come across instances where it would be an advantage ?

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.