Problem: We have N integers. The i-th integer is A_i.  Find \sum_{i=1}^{N-1}\sum_{j=i+1}^{N} (A_i \mbox{ XOR } A_j), modulo (10^9+7).  What is \mbox{ XOR }?  The XOR of integers A and B, A \mbox{ XOR } B, is defined as follows:    * When A \mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.  For example, 3 \mbox{ XOR } 5 = 6. (In base two: 011 \mbox{ XOR } 101 = 110.)

Submission attempts (in order):
import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
ba = np.array([[int(j) for j in list(format(i,'b').zfill(60))] for i in a]).T
mod = 10**9+7




ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
ba = np.array(list(format(i,'b').zfill(60)) for i in a])
mod = 10**9+7




ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
ba = np.array([[int(j) for j in list(format(i,'b').zfill(60))] for i in a])
mod = 10**9+7




ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
mod = 10**9+7


twos = np.ones(60)
for i in range(1,60):
    twos[i] = (twos[i-1]*2)%mod




ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
ba = np.array(list(format(i,'b').zfill(60)) for i in a])
#print(ba)
mod = 10**9+7



twos = [1]
for i in range(1,60):
    twos.append((twos[i-1]*2)%mod)


c0 = np.sum(ba, axis=1)



ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
ba = np.array([list(format(i,'b').zfill(60)) for i in a])
print(ba)
mod = 10**9+7



twos = [1]
for i in range(1,60):
    twos.append((twos[i-1]*2)%mod)


c0 = np.sum(ba, axis=1)



ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
ba = [format(i,'b').zfill(60) for i in a]
mod = 10**9+7


twos = np.ones(60)
for i in range(1,60):
    twos[i] = (twos[i-1]*2)%mod



c0 = np.zeros(60)



ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
mod = 10**9+7


twos = np.ones(60)
for i in range(1,60):
    twos[i] = (twos[i-1]*2)%mod



c0 = np.zeros(60)



ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
mod = 10**9+7

twos = 1
ans = 0
for i in range(0,60):
    cou1 = np.count_nonzero((a >> i) & 1)
    ans += (cou1*(n-cou1)*twos)%mod
    twos = (twos*2)%mod

ans %= mod
print(ans)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted