Problem:


Score : 400 points

Problem Statement

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.)

Constraints

2 \leq N \leq 3 \times 10^5

0 \leq A_i < 2^{60}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the value \sum_{i=1}^{N-1}\sum_{j=i+1}^{N} (A_i \mbox{ XOR } A_j), modulo (10^9+7).

Sample Input 1

3
1 2 3

Sample Output 1

6

We have (1\mbox{ XOR } 2)+(1\mbox{ XOR } 3)+(2\mbox{ XOR } 3)=3+2+1=6.

Sample Input 2

10
3 1 4 1 5 9 2 6 5 3

Sample Output 2

237

Sample Input 3

10
3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820

Sample Output 3

103715602

Print the sum modulo (10^9+7).



Sample input:
3
1 2 3


Sample output:
6

Submission status: Wrong Answer

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
import numpy as np
#======================================================#
MOD=10**9+7
def main():
    n = II()
    aa = np.array(MII())
    ans = 0
    for i in range(60):
        cnt1 = sum(aa&1)
        ans += (cnt1*(n-cnt1)*(2**i))%MOD
        aa >>= 1
    print(ans%MOD)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from collections import defaultdict
    n, *a = map(int, open(0).read().split())
    d = defaultdict(int)

    for i in a:
        x = bin(i)[2:]
        for j, k in enumerate(x[::-1], 1):
            if k == '1':
                d[j] += 1

    ans = 0
    mod = 10 ** 9 + 7
    for k, v in d.items():
        ans += pow(2, k, mod) * v * (n - v)
    ans = ans // 2
    print(ans % mod)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    a_max = max(A)
    a_len = len(A)
    keta = 0

    while True:
        a_max = a_max // 2
        keta += 1
        if a_max == 0:
            break

    # print(keta)
    t = [[0 for _ in range(keta)] for _ in range(2)]

    for k in range(keta):
        for a in A:
            a = a & (2**k)
            a = a >> k
            t[a][k] += 1

    # print(t)

    ans = 0
    for k in range(keta):
        for a in A:
            tmp = a & (2**k)
            tmp = tmp >> k
            tmp = not tmp
            ans += t[tmp][k] * (2**k)
            ans %= mod

    ans = (ans // 2) % mod
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
#import bisect
#from collections import deque
import math

#############################
#         59 58 57     1
# Ai = 0xbi bi bi ... bi
# 
#############################

#############################
#   N-1 N
#   Σ   Σ     (Ai xor Aj)
#   i=1 j=i+1
#
#   59  N-1 N       d      d
# = Σ   Σ   Σ     (bi xor bj) * 2^(d-1)
#   d=1 i=1 j=i+1
#############################

#############################
#   N-1 N       d      d
#   Σ   Σ     (bi xor bj)
#   i=1 j=i+1
#
# = (bx のうち 1 の数) * (bx のうち 0 の数)
#############################

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
A = list(map(int, input().split()))

s = 0 #sum

for d in range(1,60):
    B = [1 & (a >> (d-1)) for a in A]
    s += B.count(1) * B.count(0) * (2**(d-1))
    #print(d,B,B.count(1),B.count(0),2**(d-1),s)

#print(s)
print(s % (10**9+7))

Submission status: Wrong Answer

Solution code:
import sys


def main():
    readline = sys.stdin.readline
    N = int(readline())
    li = [-1] + list(map(int, readline().split()))
    S = 0
    p = 10 ** 9 + 7
    for i in range(1, N):
        for j in range(i + 1, N + 1):
            S += (li[i] ^ li[j]) % p
    print(S)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    li = [-1] + list(map(int, input().split()))
    S = 0
    for i in range(1, N):
        for j in range(i + 1, N + 1):
            S += (li[i] ^ li[j]) % (10 ** 9 + 7)
    print(S)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
n,*a=map(int,open(0).read().split())
mod=10**9+7
a=np.array(a)
b0=np.array([0 for i in range(60)])
b1=np.array([0 for i in range(60)])
for i in range(60):
  c=len(a[a&1==1])
  b1[i]=c
  b0[i]=n-c
  a>>=1
ans=0
for i in range(60):
  ans+=(b0[i]*b1[i]*pow(2,i,mod))
  ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
m2 = [1 for i in range(60)]
for i in range(1,60):
    m2[i] = (m2[i-1]*2)%mod

n1 = np.zeros(60,dtype=int)
for i in a:
    sai = list(map(lambda x:int(x),str(format(i,'060b'))))
    n1 += sai

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

print(ans)
'''

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
m2 = [1 for i in range(60)]
for i in range(1,60):
    m2[i] = (m2[i-1]*2)%mod

n1 = [0 for i in range(60)]
for j in range(60):
    md = 1
    for i in range(n):
        n1[j] += (a[i]//md)%2
    md *= 2

'''
ans = 0
for i in range(n-1):
    for j in range(60):
        if al[i][j] == 0:
            ans = (ans+(sa[n-1][j]-sa[i][j])*m2[j])%mod
        else:
            ans = (ans+(n-1-i-sa[n-1][j]+sa[i][j])*m2[j])%mod

print(ans)
'''

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
m2 = [1 for i in range(60)]
for i in range(1,60):
    m2[i] = (m2[i-1]*2)%mod

al = [[(a[j]//(2**i))%2 for i in range(60)] for j in range(n)]
sa = [[0 for i in range(60)] for j in range(n)]
for i in range(n):
    for j in range(60):
        sa[i][j] = sa[i-1][j]+al[i][j]

'''
ans = 0
for i in range(n-1):
    for j in range(60):
        if al[i][j] == 0:
            ans = (ans+(sa[n-1][j]-sa[i][j])*m2[j])%mod
        else:
            ans = (ans+(n-1-i-sa[n-1][j]+sa[i][j])*m2[j])%mod

print(ans)
'''

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))

max_digit = 61

count_0 = [0 for _ in range(max_digit)]
count_1 = [0 for _ in range(max_digit)]

for i in range(len(a)):
    num_str = bin(a[i])[2:]
    # print(num_str)
    for j in range(len(num_str)):
        # print(num_str[-j-1])
        if num_str[-j-1] == "1":
            count_1[-j-1] += 1

# for i in range(max_digit):
#     count_0[i] = n-count_1[i]

ans = 0
# count = 1
# for i in range(61):
#     # tmp = count_0[-i-1]*count_1[-i-1]
#     tmp = count_1[-i-1]*(n-count_1[-i-1])
#     ans += tmp*count
#     count = (count*2) % mod
print(ans % mod)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))

count_0 = [0 for _ in range(61)]
count_1 = [0 for _ in range(61)]

for i in range(len(a)):
    num_str = bin(a[i])[2:]
    # print(num_str)
    for j in range(len(num_str)):
        if num_str[-j-1] == "0":
            count_0[-j-1] += 1
        else:
            count_1[-j-1] += 1

# print(count_0)
# print(count_1)

ans = 0
count = 1
for i in range(61):
    tmp = count_0[-i-1]*count_1[-i-1]
    ans += tmp*count
    count = (count*2) % mod
print(ans % mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = list(map(int,input().split()))
maxi = max(lis)
bi = len(format(maxi,"b"))
zero = [0]*bi
one = [0]*bi
for i in range(bi):
    for j in range(N):
        tmp = "0"*(bi-len(format(lis[j],"b"))) + format(lis[j],"b")
        
        if tmp[bi-1-i] == "1":
            one[bi-1-i] += 1
        else:
            zero[bi-1-i] += 1

result = 0

for i in range(bi):
    result += (zero[bi-1-i]*one[bi-1-i]*(2**(i)))%(10**9+7)
print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
bo=[0]*61
bz=[0]*61
for i in a:
  t=format(i,'061b')
  for j in range(61):
    if t[j]=='0':
      bz[j]+=1
    else:
      bo[j]+=1
bo=bo[::-1]
bz=bz[::-1]
x=0
for i in range(61):
  x+=bo[i]*bz[i]*(2**i)
print(x)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split());c=0;i=1
for _ in[0]*61:i**=2;t=sum(i&b and 1for b in a);c+=t*(n-t)*i;c%=10**9+7
print(c)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split());c=i=0
for _ in[0]*61:i**=2;t=sum(i&b and 1for b in a);c+=t*(n-t)*i;c%=10**9+7
print(c)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
A=list(map(int,input().split()))

B=list(itertools.combinations(A, 2))
SUM=0

for b1, b2 in B:
  SUM=SUM+ b1^b2

print(SUM%10**9+7)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
A=list(map(int,input().split()))

B=list(itertools.combinations(A, 2))
SUM=0

for b1, b2 in B:
  SUM= (SUM+(b1^b2))%(10**9+7)

print(SUM%10**9+7)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
A=list(map(int,input().split()))

B=list(itertools.combinations(A, 2))
SUM=0

for b1, b2 in B:
  SUM= SUM+((b1^b2)%(10**9+7))

print(SUM%10**9+7)

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))
mx = max(A)
d = {i:0 for i in range(len(str(bin(mx))))}
for a in A:
  for i in range(len(str(bin(a)))-2):
    if (a>>i)&1:
      d[i] += 1

ans = 0
for k, v in d.items():
  ans += v*(10-v) * (2**k)
  ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c1_list = [0]*60
for i in range(n):
  b = format(a[i], '060b')
  print(b)
  for j in range(len(b)):
    if b[j] == "1":
      c1_list[j] += 1
count = 0
for i in range(60):
  count = (count + c1_list[i]*(n-c1_list[i])*2**(59-i)) % 1000000007
print(count)

Submission status: Wrong Answer

Solution code:
def main():
    M = 1000000007
    n = int(input())
    a = list(map(int, input().split()))
    bit_size = len(bin(max(a))[2:])
    for i in range(n):
        a[i] = bin(a[i])[2:].zfill(bit_size)

    print(bit_size)

    sum = 0
    for i in range(bit_size):
        one = 0
        zero = 0
        for j in range(n):
            if a[j][i] == '1':
                one += 1
            else: 
                zero += 1
        sum += (2**(bit_size - i - 1) % M) * (one % M) * (zero % M)
        sum %= M
    print(sum)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7

ans = 0
for i in range(60):
    X = sum([1 for x in A if (x >> 1) & 1])
    ans += (1 << i) * X * (N - X)
    ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
aa = list(map(int, input().split()))
mod = 10**9+7
res = 1
pow2 = 1
ans = 0
for i in range(60):
    cnt = np.count_nonzero(np.array(aa)&2)
    ans = (ans + cnt * (n-cnt) * res)%mod
    res = (res*2)%mod
    pow2*=2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = list(format(a[i],'0b').zfill(60))
g = [0 for i in range(60)]
for i in range(60):
    for j in range(n):
        if a[j][i] == '1':
            g[i] += 1
ans = 0
for i in range(len(g)):
    ans += g[i]*(n-g[i])*(pow(2,64-i,10**9+7))
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = list(format(a[i],'0b').zfill(65))
g = [0 for i in range(65)]
for i in range(65):
    for j in range(n):
        if a[j][i] == '1':
            g[i] += 1
ans = 0
for i in range(len(g)):
    ans += g[i]*(n-g[i])*(2**(64-i))
    ans = ans%1024
print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = list(format(a[i],'0b').zfill(65))
g = [0 for i in range(65)]
for i in range(65):
    for j in range(n):
        if a[j][i] == '1':
            g[i] += 1
ans = 0
for i in range(len(g)):
    ans += g[i]*(n-g[i])*(2**(64-i))
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    a = tuple(map(int,input().split()))
    b = []
    mod = 10**9+7

    for i in range(n-1):
        for j in range(i+1,n):
            b.append((a[i]^a[j])%mod)

    ans = sum(b)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
mod = 1000000007

n = int(input())
a = np.array(list(map(int, input().split())))

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod = 1000000007

n = int(input())
a = np.array(list(map(int, input().split())))

bit = 1
ans = 0
for n in range(60):
    a_and = a & 1
    cnt_one = np.count_nonzero(a_and)
    ans += (cnt_one * (n - cnt_one) * bit) % mod
    a >>= 1
    bit *= 2
    bit % mod

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
p=10**9 + 7 
l=[0]*60
ans=0
for i in range(60):
    for j in a:
        l[i]+=(j>>i)&1
    ans+=(2**i*l[i]*(n-l[i]))%p
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))

b=max(a)
k=0

while b!=0:
    b=b//2
    k+=1

ans=0

for i in range(k):
    x=0
    y=0
    for j in range(n):
        if (a[j]>>i)%2==1:
            x+=1
        else:
            y+=1
    ans+=(2**i)*(x*y)
print(ans)

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))

ans = 0
twopow = 1
for n in range(60):
    one = sum( ((Ai >> n) & 1) for Ai in A )
    zero = N - one
    ans = ans + (one * zero) * twopow % MOD
    twopow = twopow << 1 % MOD 

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
mod = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
a = np.array(a)
ans = 0
# for bin_a in map(bin, a):
d = 1
num_of_one_per_keta = []
while d < (1 << 61):
    cnt = np.count_nonzero(a & d)
    num_of_one_per_keta.append(cnt)
    # ans += (N - cnt) * cnt * d
    # ans %= MOD
    d <<= 1
print(num_of_one_per_keta)
ans = 0
for i, num_of_one in enumerate(num_of_one_per_keta):
    ans += (n-num_of_one)*num_of_one*pow(2, i, mod) % mod
print(ans % mod)

Submission status: Wrong Answer

Solution code:
K = 1000000009
N = int(input())
A = [int(a) for a in input().split()]
li = [0] * 60
for n in range(N):
    for i in range(60):
        li[i] += A[n] >> i & 1
ans = 0
for i in range(60):
    ans += (1 << i) * li[i] * (N - li[i])
    ans %= K
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
A = np.array(input().split(), np.int)
#print(A)

cnt = 0
for i in range(61):
    B = (A>>i)&1
    z = np.count_nonzero(B)
    cnt += z*(N-z)*(2**(i))

print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
A = list(map(int, input().split()))
A.sort()

ml = len(format(A[-1], 'b'))
bA = [list(map(int, list(format(val, '061b')))) for val in A]
#bAT = list(zip(*bA))
#bAT = bAT[::-1]
nbA = np.asarray(bA).sum(axis=0)[::-1]

cnt = 0
for i, val in enu(nbA):
    cnt += (N-val)*val*(2**(i))
    cnt %= MOD

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
MOD = 1e+9 + 7
shift = 70
a = [int(i) for i in input().split()]

b = [0 for _ in range(shift)]

for i in a:
  for j in range(shift):
    b[j] += (i >> j) & 1

ans = 0
for i, j in enumerate(b):
  second = 1
  for _ in range(i):
    second *= 2
    second %= MOD
  ans += ((j * (N - j)) * second) % MOD
  ans %= MOD
  
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
MOD = 1e+9 + 7
shift = 70
a = [int(i) for i in input().split()]

b = [0 for _ in range(shift)]

for i in a:
  for j in range(shift):
    b[j] += (i >> j) & 1

ans = 0
for i, j in enumerate(b):
  second = 1
  for _ in range(i):
    second *= 2
    second %= MOD
  ans += (j * (N - j)) * second
  ans %= MOD
  
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
MOD = 1e+9 + 7
a = [int(i) for i in input().split()]

b = [0 for _ in range(100)]

for i in a:
  for j in range(100):
    b[j] += (i >> j) & 1

ans = 0
for i, j in enumerate(b):
  second = 1
  for _ in range(i):
    second *= 2
    second %= MOD
  ans += (j * (N - j)) * second
  ans %= MOD
  
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
MOD = 1e+9 + 7
a = [int(i) for i in input().split()]

b = [0 for _ in range(60)]

for i in a:
  for j in range(60):
    b[j] += (i >> j) & 1

ans = 0
for i, j in enumerate(b):
  second = 1
  for _ in range(i):
    second *= 2
    second %= MOD
  ans += (j * (N - j)) * second
  ans %= MOD
  
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
MOD = 1e+9 + 7
a = [int(i) for i in input().split()]

b = [0 for _ in range(60)]

for i in a:
  for j in range(60):
    b[j] += (i >> j) & 1

ans = 0
for i, j in enumerate(b):
  ans += (j * (N - j)) * 2**i
  ans %= MOD
  
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
MOD = 1e+9 + 7
a = [int(i) for i in input().split()]

ans = 0
for i in range(N):
  for j in range(i+1, N):
    ans += a[i] ^ a[j]
    ans %= MOD
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
count = [0] * 60
m = 1000000007
def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K * x) % 1000000007
        x = (x * x) % 1000000007
        n //= 2
    return (K * x) % 1000000007
mul = [pow_k(2,59-i) for i in range(60)]
for a in A:
    b = bin(a)
    for i in range(1,len(b)-1):
        if b[-i] == '1':
            count[-i] += 1
print(sum([count[i]*(N-count[i])*mul[i]%m for i in range(60)]))

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = np.array(read().split(), np.int64)

mod = 10 ** 9 + 7
ans = 0

for i in range(61):
    b = a >> i & 1
    x = len(b) - sum(b)
    y = n - x
    z = x * y
    z *= 2 ** i
    z %= mod
    ans += z
ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
list=[]
for i in range(100):
    list.append(0)
ans=0
mod=(10**9)+7

print(list)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

li = [[0,0] for _ in range(63)]

for i in range(n):  
    s = Base_10_to_n(a[i],2).zfill(63)
    for j in range(63):
        if s[j] == "1":
            li[62-j][1] += 1
        else:
            li[62-j][0] += 1

point = 0
mod = 10**9+7

for i in range(61):
    kazu = li[i][0]*li[i][1]
    kazu %= mod
    if kazu == 0:
        continue
    for j in range(i):
        kazu *= 2
        kazu %= mod
    point += kazu
    point %= mod

print(point)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

li = [[0,0] for _ in range(61)]

for i in range(n):  
    s = Base_10_to_n(a[i],2).zfill(61)
    for j in range(61):
        if s[j] == "1":
            li[60-j][1] += 1
        else:
            li[60-j][0] += 1

point = 0
mod = 10**9+7

for i in range(61):
    kazu = li[i][0]*li[i][1]
    kazu %= mod
    if kazu == 0:
        continue
    for j in range(i):
        kazu *= 2
        kazu %= mod
    point += kazu
    point %= mod

print(point)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

li = [[0,0] for _ in range(61)]

for i in range(n):  
    s = Base_10_to_n(a[i],2).zfill(61)
    for j in range(61):
        if s[j] == "1":
            li[60-j][1] += 1
        else:
            li[60-j][0] += 1

point = 0
mod = 10**9+7

for i in range(61):
    mi = min(li[i])
    if mi == 0:
        continue
    for j in range(i):
        mi *= 2
        mi %= mod
    point += mi
    point %= mod

point *= n-1
point %= mod

print(point)

Submission status: Wrong Answer

Solution code:
import numpy as np

M = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))

zero = np.zeros(62, dtype=np.int64)
one = np.ones(62, dtype=np.int64)
rg = np.arange(62, dtype=np.int64)


def bitcnt(a):
    j = 0
    bits = np.zeros(62, dtype=np.int64)
    while a:
        bits[j] = a & 1
        a >>= 1
        j += 1
    return bits


ans = 0
a1 = bitcnt(A[0])
a0 = one - a1
import pdb

# pdb.set_trace()
for i in range(1, N):
    bits1 = bitcnt(A[i])
    bits0 = one - bits1
    ans += np.sum(2 ** rg * (a0 * bits1) % M) % M
    ans %= M
    ans += np.sum(2 ** rg * (a1 * bits0) % M) % M
    ans %= M
    a1 += bits1
    a0 += bits0

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

d_cumsum = np.zeros(60, dtype='i8')
for v in a:
    d_cumsum += np.array(list(map(int, list(format(v, '060b')))))

res = 0
mod = 10**9 + 7
for i, d in enumerate(reversed(d_cumsum)):
    res += (2**i * d * (n-d)) % mod
    res %= mod

print(res)

Submission status: Wrong Answer

Solution code:
import math
import fractions
import sys
import itertools
import numpy as np
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


N=input1()
A=np.array(input_array())
mod=10**9-7
s=0

for i in range(60):
	c1=np.count_nonzero(A & 1)
	#(i桁目) * (2進数表現:1の個数) * (2進数表現:0の個数)
	s+=2**i*c1*(N-c1)
	A = A >> 1

print(s % mod)

Submission status: Wrong Answer

Solution code:
import math
import fractions
import sys
import itertools
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


N=input1()
A=input_array()
xor=0
for i in range(N-1):
	for j in range(i+1,N):
		xor+=int(bin(A[i]^A[j]),2)

print(xor % (10**9-7))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
p = 10**9 + 7
num_a = np.array([0]*60)
str_a = []
for i in a:
  a_str = list(map(int, format(i, 'b').zfill(60)))
  num_a = num_a + np.array(a_str)
num_a =reversed(num_a)
ans = 0
for i, j in enumerate(num_a):
  ans =  (ans + j*(n-j)*2**i)%p

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
p = 10**9 + 7
num_a = np.array([0]*60)
str_a = []
for i in a:
  a_str = list(format(i, 'b').zfill(60))
  a_str = list(map(int, a_str))
  num_a = num_a + np.array(a_str)
num_a =reversed(num_a)
ans = 0
for i, j in enumerate(num_a):
  ans =  (ans + j*(n-j)*2**i)%p

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
*A, = map(int, input().split())
p = 10**9+7
A = [list(format(a, '060b')) for a in A]
s = 0
for i in range(60):
    Ai = [int(a[i]) for a in A]
    print(Ai)
    c0 = Ai.count(0)
    c1 = Ai.count(1)
    c = c0*c1
    s = (s+c*(2**(59-i))) % p
print(s)

Submission status: Wrong Answer

Solution code:
from sys import setrecursionlimit
n = "0"+input()
N = len(n)
point = 0
for i in range(1,N):
    one_push = 1+point+10-int(n[i])
    no_push = point + int(n[i])
    point = min(one_push,no_push)
print(point)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))

P = 1e9 + 7
import itertools
s = int(0)
for x, y in itertools.combinations(As, 2):
    s = (s + (x ^ y)) % P

print(int(s))

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = 0
for i in range(63):
    b = (a >> i) & 1
    x = np.count_nonzero(b)
    x = x * (n - x)
    ans += x * pow(2, i, mod) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = 0
for i in range(63):
    b = (a >> i) & 1
    print(b)
    x = np.count_nonzero(b)
    x = x * (n - x)
    ans += x * pow(2, i, mod) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
mod = 10**9+7
a = np.array(list(map(int,input().split())))
ans = 0
for i in range(60):
    #aをiビット右にずらす、iは60桁目まで、&1で対象のビットが1のもの以外を0にその数をカウントする。
    b = np.count_nonzero(a >>i&1)
    ans += ((2**i)*(n-b)*b)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
mod = 1e9+7
ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans += (A[i] ^ A[j])%mod
        ans %= mod
print(int(ans))

Submission status: Wrong Answer

Solution code:
mod = 10**9+7

def xor(a, b):
    A = str(bin(a))
    B = str(bin(b))

    A = A[2:]
    B = B[2:]

    if len(A) >= len(B):
        n = len(A)
        for i in range(len(A) - len(B)):
            B = '0' + B
    else:
        n = len(B)
        for i in range(len(B) - len(A)):
            A = '0' + A

    C = ''

#    print('A = {}, B = {}'.format(A, B))

    for i in range(n):
        if A[i] == B[i]:
            C = C + '0'
        else:
            C = C + '1'

    return int(C, 2) % mod


n = int(input())
a = list(map(int,input().split()))

ans = 0

for i in range(n):
    for j in range(n-i-1):
        ans = (ans + xor(a[i], a[i+j+1])) % mod
        print('xor(a[{}], a[{}]) = {}'.format(i, i+j+1, xor(a[i], a[i+j+1])))

print(ans%(mod))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(0, n-1):
    for j in range(i+1, n):
        ans+= l[i]^l[j]
print(ans)

Submission status: Wrong Answer

Solution code:
mod=1000000007
def sumXOR(arr, n):
    sum = 0
    for i in range(0, 64):
        #  Count of zeros and ones
        zc = 0
        oc = 0
        # Individual sum at each bit position
        idsum = 0
        for j in range(0, n):
            if (arr[j] % 2 == 0):
                zc = zc + 1

            else:
                oc = oc + 1
            arr[j] = int(arr[j] / 2)

            # calculating individual bit sum
        idsum = oc * zc * (1 << i)

        # final sum
        sum = sum + idsum

    return sum
n=int(input())
arr=list(map(int,input().split()))
print(sumXOR(arr,n)%mod)

Submission status: Wrong Answer

Solution code:
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
  N = int(readline())
  A = np.array(read().split(), np.int64)
  ans = 0
  for i in range(63):
    B = (A>>i)&1
    x = np.count_nonzero(B)
    y = N - x
    x = x*y
    for _ in range(i):
      x *= 2
      x %= MOD
    ans += x
  print(ans)
  
  
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys

import numpy as np

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = np.array(A)
    B = 61

    ans = 0
    for b in range(B):
        cnt_1 = np.sum((A >> b) & 1)
        ans += 2 ** b * cnt_1 * (N - cnt_1)
        ans %= P
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

ret = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        continue

print(ret)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    b = sum(map(lambda x: (x >> i)&1, a))
    c = n - b
    ans += b * c * i % mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = [0 for i in range(60)]
for i in range(n):
    b = bin(a[i])
    for i in range(len(b)-2):
        x[-i-1] += int(b[-i-1])
mod = 10**9+7
ans = 0
two = 1
for i in range(1,60):
    ans = (ans + x[-i]*(n-x[-i])*two)%mod
    two = two*2%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
ans = 0

for j in reversed(range(60)):
    one = 0
    zero = 0
    for i in range(n):
        b = str(bin(a[i]))[2:]
        c = b.zfill(60)
        s = int(c[j])
        if s==0:
            zero += 1
        else:
            one += 1
    ans_bit = zero * one
    ans += (ans_bit)*(2**(60-j)) % mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
n=int(input())
mod=10**9+7
l=list(map(int,input().split()))
d=len(str(bin(max(l))))-2
ll=[[0,0] for i in range(d)]
ans=0
for i in l:
  f=bin(i)[2:]
  for v in range(len(f)):
    ll[v][int(f[-1-v])]+=1
for i,(a,s) in enumerate(ll):
  ans+=pow(2,i,mod)*a*s%mod
  ans%=mod
print(ans)