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 itertools
n = int(input())
a = list(map(int, input().split(" ")))
count = 0
for i, j in itertools.combinations(a, 2):
  count += i^j
print(count)

Submission status: Wrong Answer

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

mod = 10**9+7

table = [0 for i in range(60)]
for i in a:
    for t in range(60):
        if i&1:
            table[t] += 1
        i >>= 1

ans = 0
for i in a:
    for j, s in enumerate(table):
        if i&1:
            ans += (n-s)*2**j
            ans %= mod
        else:
            ans += s*2**j
            ans %= mod
        i >>= 1
print(ans//2)

# -- | 01 | 10 | 11
# 01 | 00 | 11 | 10
# 10 | 11 | 00 | 01
# 11 | 10 | 01 | 00
# 12

# --- | 001 | 100 | 111
# 001 | 000 | 101 | 110
# 100 | 101 | 000 | 011
# 111 | 110 | 011 | 000
# 28

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    
    ans = 0
    for i in range(N-1):
        for j in range(i+1, N):
            ans += A[i]^A[j]
            ans %= int(10e9)
    print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())


def run():
    N, *A = mapread()
    maxA = max(A)
    L = maxA.bit_length()
    subs = [0] * L
    for k in range(L):
        sum = 0
        for a in A:
            if (a >> k) & 1:
                sum += 1 << k
            sum %= mod
        subs[k] = sum

    sumA = 0
    for a in A:
        sumA += a
        sumA %= mod
    ret = 0
    ret += (sumA * N) % mod
    ret += (sumA * N) % mod

    sub_sum = 0
    for a in A:
        sums = 0
        for k in range(L):
            if (a >> k) & 1:
                sums += subs[k] * 2
                sums %= mod
        sub_sum += sums
        sub_sum %= mod

    ret -= sub_sum
    ret %= mod
    ret //= 2
    print(ret)


if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
import queue
import numpy as np
import math

n = int(input())
A = list(map(int, input().split()))
A = np.array(A,np.int64)
ans = 0

for i in range(60 + 1):
    count1 = 0
    for a in A:
        count1 += (a >> i) & 1

    count0 = len(A) - count1
    ans += count1*count0 * pow(2, i)
    ans%=1000000007

print(ans)

Submission status: Wrong Answer

Solution code:
import queue
import numpy as np
import math

n = int(input())
A = list(map(int, input().split()))
A = np.array(A,np.int64)
ans = 0

for i in range(60 + 1):
    count1 = (A >> i) & 1

    count0 = len(A) - count1
    ans += count1*count0 * pow(2, i)
    ans%=1000000007

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=np.array([int(x) for x in input().split()])

ans=0
M=pow(10,9)+7
for i in range(100):
  one=np.sum((A>>i)&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i,M)
  ans%=M
  #print(one,zero)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=np.array([int(x) for x in input().split()])

ans=0
M=pow(10,9)+7
for i in range(100):
  one=np.sum((A>>i)&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i)
  ans%=M
  #print(one,zero)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=np.array([int(x) for x in input().split()])

ans=0
M=pow(10,9)+7
for i in range(100):
  one=np.sum((A>>i)&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i)
  #ans%=M
  #print(one,zero)
print(ans%M)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=np.array([int(x) for x in input().split()])

ans=0
M=pow(10,9)+7
for i in range(100):
  one=np.sum((A>>i)&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i)
  ans%=M
  #print(one,zero)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
M=10**9+7
A=np.array([int(x) for x in input().split()])

ans=0
for i in range(100):
  #one=sum([a>>i&1 for a in A])
  one=np.sum((A>>i)&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i,M)
  ans%=M
  #print(one,zero)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
M=10**9+7
A=[int(x) for x in input().split()]
A=np.array(A)

ans=0
for i in range(70):
  #one=sum([a>>i&1 for a in A])
  one=np.sum((A>>i)&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i,M)
  ans%=M
  #print(one,zero)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
M=10**9+7
A=[int(x) for x in input().split()]
A=np.array(A)

ans=0
for i in range(60):
  #one=sum([a>>i&1 for a in A])
  one=np.sum((A>>i)&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i)
  ans%=M
  #print(one,zero)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
M=10**9+7
A=[int(x) for x in input().split()]
A=np.array(A)

ans=0
for i in range(60):
  #one=sum([a>>i&1 for a in A])
  one=np.sum(A>>i&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i)
  ans%=M
  #print(one,zero)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
M=10**9+7
A=[int(x) for x in input().split()]
A=np.array(A)

ans=0
for i in range(60):
  #one=sum([a>>i&1 for a in A])
  one=np.sum(A>>i&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i,M)
  ans%=M
  #print(one,zero)
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]

a_bin=[]

for i in a:
    a_bin.append(format(i, '#062b')[2:])



def get_keta_num(keta,a_list):
    zero=0
    one=0
    for i in a_list:
        if i[-keta]=="0":
            zero+=1
        else:
            one+=1
    return zero*one

ans=0
for i in range(1,61):
    ans+=(2**(i-1))*get_keta_num(i,a_bin)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
MOD = 10**9+7

n = int(sys.stdin.buffer.readline())
a = np.fromstring(sys.stdin.buffer.readline(), dtype = np.int64, sep = ' ')
ans = 0
for i in range(60):
    s = (a&1).sum()
    ans += s*(n-s) * 2**i
    ans %= MOD
    a >>= 1
print(ans)

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
n = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
zero = defaultdict(int)
one = defaultdict(int)
for a in A:
    for i in range(60):
        if a &(1<<i):
            one[i] += 1
        else:
            zero[i] += 1
ans = 0
for a in A:
    for i in range(60):
        if a &(1<<i):
            ans += pow(2,i,mod)*zero[i]
        else:
            ans += pow(2,i,mod)*one[i]
        ans %= mod
print((ans//2)%mod)

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(61):
    count0=0
    count1=0
    for j in a:
        if not (j>>i & 1):
            count0+=1
        if j>>i & 1:
            count1+=1
    ans+=((count0*count1)*(2**i))%mod
    print(count0,count1)
print(ans%mod)

Submission status: Wrong Answer

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

mod = 10**9+7
ans = 0

tmp = 0
for aa in a:
    ans += (tmp & aa) << 1
    ans %= mod
    tmp |= aa

print(((n-1)*sum(a)%mod-ans)%mod)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    ans = 0
    mod = 10 ** 9 + 7
    for d in range(59):
        # d桁目ごとに考える
        x = 0
        for a in A:
            if (a >> d) & 1:
                x += 1
        ans += x * (n-x) * 2**d
        ans %= mod
    print(ans)
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(x) for x in input().split()]
ans = 0
mod = 10 ** 9 + 7
# 制約がai <= 2^60なので
for d in range(30):
    # d桁目ごとに考える
    x = 0
    for a in A:
        if (a >> d) & 1:
            x += 1
    ans += x * (n-x) * 2**d
    ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(x) for x in input().split()]
ans = 0
mod = 10 ** 9 + 7
for d in range(21):
    # d桁目ごとに考える
    x = 0
    for a in A:
        if (a >> d) & 1:
            x += 1
    ans += x * (n-x) * 2**d
    ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(x) for x in input().split()]
ans = 0
mod = 10 ** 9 + 7
for d in range(20):
    # d桁目ごとに考える
    x = 0
    for a in A:
        if (a >> d) & 1:
            x += 1
    ans += x * (n-x) * 2**d
    ans %= mod
print(ans)

Submission status: Wrong Answer

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

B=[[] for i in range(n)]
for i in range(n):
    B[i]= [int(i) for i in bin(A[i])[2:]]
    B[i] = [0]*(60-len(B[i]))+B[i]

TB=[[0]*n for i in range(60)]
for i in range(60):
    for j in range(n):
        TB[i][j] = B[j][i]
        
# import numpy as np
#print(TB)
ans=0
for i in range(60):
    now=TB[i]
    q=now.count(1)
    ans+= pow(2,59-i,mod)* (q*(q-1))%mod //2
    ans%=mod
ans*=2
ans%=mod


last=0
for i in A:
    last+=i%mod
    last%=mod
last*=(n-1)
last%=mod
print((last-ans)%mod)

Submission status: Wrong Answer

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

B=[[] for i in range(n)]
for i in range(n):
    B[i]= [int(i) for i in bin(A[i])[2:]]
    B[i] = [0]*(60-len(B[i]))+B[i]

TB=[[0]*n for i in range(60)]
for i in range(60):
    for j in range(n):
        TB[i][j] = B[j][i]
        
import numpy as np
ans=0
for i in range(60):
    now=TB[i]
    q=np.count_nonzero(now)
    ans+= pow(2,59-i,mod)* (q*(q-1))%mod //2
    ans%=mod
print(((sum(A)%mod)*(n-1)%mod-2*ans)%mod)

Submission status: Wrong Answer

Solution code:
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

N = cin()
A = cin()
INF = 1e9 + 7

res = [0 for _ in range(65)]
for i in range(65):
    c0 = 0
    c1 = 0
    for j in range(N):
        if bool(A[j] & (1 << i)):  c1 += 1
        else:  c0 += 1
    res[i] = c0 * c1
ans = 0
for i in range(65):  ans = (ans + (2 ** i) * res[i]) % INF
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])

ans = 0
mod = pow(10, 9)+7
for i in range(100):
  c = np.sum((a>>i)&1)
  ans += c*(n-c)*pow(2, i, mod)%mod
  ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
M = 10**9+7
n = int(input())
l = list(map(int,input().split()))
x = max(l)
s = bin(x)
u = len(s)-2
o = [0]*u
for i in l:
    x = bin(i)
    x = x[2:]
    a = list(x)
    d = u - len(a)
    a = (["0"] * d) + a
    j = 0
    while(j < len(o)):
        if a[j] == "1":
            o[j] = o[j]+1

        j = j+1

#print(o)
cnt = 0
z = len(o)*[0]
for i in range(len(o)):
    z[i] = len(l)-o[i]

o = o[::-1]
z = z[::-1]
for r in range(len(l)-1):
    i = l[r]
    x = bin(i)
    x = x[2:]
    a = list(x)
    d = u-len(a)
    a = (["0"]*d)+a
    a = a[::-1]
    j = u - 1
    while(j > -1):
        if a[j] == "1":
            o[j] = o[j] - 1

        if a[j] == "0":
            z[j] = z[j]-1

        j = j - 1

    j = u-1
    while(j > -1):
        if a[j] == "0":
            z[j] = z[j]-1
            cnt = (cnt+((2**j)*o[j])%M)%M

            if a[j] == "1":
                cnt = (cnt + ((2 ** j) * z[j]) % M) % M

        j = j-1

    j = u-1
    #print(cnt)

print(cnt)

Submission status: Wrong Answer

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

res = 0
for i in range(n):
  for j in range(i+1, n):
    res += (a_lst[i] ^ a_lst[j])
print(res)

Submission status: Wrong Answer

Solution code:
#気が向いたら後で解く

Submission status: Wrong Answer

Solution code:
import numpy as np

n=int(input())
a=np.array(list(map(int,input().split())))
mod=10**9+7

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np

N=int(input().rstrip('\n'))
A=np.array([int(x) for x in input().rstrip('\n').split()])
res = 0
for i in range(60):
  n = sum(A%2)
  A = A//2
  t = 2**i
  res += n*(N-n)*t
  res = res%(7+10**9)
  if all(x==0 for x in A):
    break
print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit


N = int(input())
A = np.array(list(map(int, input().split())), dtype=np.int64)
MOD = 1_000_000_007


@njit("i8(i8,i8[:],i8)")
def solve(N, A, MOD):
    ans = 0
    two_exp = 1
    for i in range(60):
        one_cnt = 0
        for j in range(N):
            one_cnt += A[j] >> i & 1
        ans += one_cnt * (N - one_cnt) * two_exp
        ans %= MOD
        two_exp <<= 1
        two_exp %= MOD
    return ans


print(solve(N, A, MOD))

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import itertools


def input():
    return sys.stdin.readline().rstrip()


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


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 bit in range(10):
    m = 1 << bit
    # bit桁目のbitが立っている時の数
    c = sum(a&m for a in A) >> bit
    # bit桁目の1の合計
    ans += (c*(N-c))<<bit
    # 繰り上がりのない足し算
    ans %= mod
print(ans)

Submission status: Wrong Answer

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

bit = [0] * 60
mod = 10 ** 9 + 7
ans = 0
for i in range(20):
    c = 0
    for j in range(n):
        c += int(a[j] & 1)
        a[j] //= 2
    ans = (ans + c * (n - c) * (2 ** i)) % mod

print(ans)

Submission status: Wrong Answer

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

bit = [0] * 60
mod = 10 ** 9 + 7
ans = 0
for i in range(20):
    c = 0
    for j in range(n):
        c += a[j] & 1
        a[j] //= 2
    ans = (ans + c * (n - c) * (2 ** i)) % mod

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
mod = 10 ** 9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
 
tmp = 0
for n in range(len(bin(max(A)))-2):   # 最大桁数は、最も大きい数値の2進数の桁数
    num_1 = np.count_nonzero((A >> n)&1)   # 1の数をカウント
    print((A >> n)&1)
    num_0 = N - num_1                      # 0の数をカウント
    mul = num_1 * num_0   # 0 XOR 1の回数
    tmp += ((2 ** n)*mul) % mod

print(tmp%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np 
# 初期入力
mod = 10**9 +7
ans =0
N =int(input())
A =list(map(int,input().split()))
A_np =np.array(A,dtype=np.int64)

# xor
for a in range(N-1):
    ans +=np.sum(A_np[a+1:] ^A[a]) %mod
print(ans %mod)

Submission status: Wrong Answer

Solution code:
mod = pow(10,9)+7
N = int(input())

A =map(lambda x:int(bin(int(x))[2:]) ,input().split())

counter = 0
for a in A:
    counter += a

A = str(counter)
L = len(A)
tmp = 0
for i in range(L):
    tmp += int(A[i])*(N-int(A[i]))*(2**(L-i-1))
    
print(tmp%mod)

Submission status: Wrong Answer

Solution code:
mod = pow(10,9)+7
N = int(input())

A =map(lambda x:int(bin(int(x))[2:]) ,input().split())

counter = 0
for a in A:
    counter += a

A = str(counter)
L = len(A)
tmp = 0
for i in range(L):
    tmp += int(A[i])*(N-int(A[i]))*2**(L-i-1)
    tmp %= mod
print(tmp)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
mod = 10e9+7
ans = 0
for i in range(60):
    x = 1<< i
    l = len([1 for j in a if j & x])
    ans += x * l * (n-l) % mod
    ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()

n=ii()
a=lmi()
ans=0
for i in range(60):
  x=0
  for j in range(n):

    if (a[j]>>i)&1:
      x+=1

  num=x*(n-x)*2**i
  ans+=num

print(ans)

Submission status: Wrong Answer

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

m = 1000000007

result = 0
for bit in range(60):
    m = 1 << bit
    c = sum(a & m for a in A) >> bit
    result += (c * (N - c)) << bit
    result %= m
print(result)

Submission status: Wrong Answer

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

MOD = 1e9+7
ans = 0

for i in range(60):
    cnt = 0
    for a in A:
        cnt += a>>i&1
    ans += cnt*(n-cnt)*2**i
    ans %= MOD

print(int(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(60):
    cnt = 0
    for a in A:
        cnt += a>>i&1
    ans += cnt*(n-cnt)*2**i
    ans %= MOD

print(ans)

Submission status: Wrong Answer

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

bitlist = [0] * 60

for i in A:
    for index, num in enumerate(reversed(bin(i)[2:])):
        if num == "1":
            bitlist[index] += 1
ans = 0
for bit, num in enumerate(bitlist):
    ans += num * (N-num) * (2 ** bit)

print(ans)

Submission status: Wrong Answer

Solution code:
##かっこいい実装
import numpy as np
#mod = 10**9+7
#n = int(input())
#a = np.fromstring(input(), dtype = np.int64, sep = ' ')
#
#result = 0
#for i in range(60):
#    count_one = int((a&1).sum())
#    result += count_one*(n-count_one)*(2**i)
#    a >>= 1
#print(result%mod)

N = int(input())
A = np.fromstring(input(),dtype = np.int64, sep = ' ')
Large = 10**9 + 7
ans = 0
for i in range(60):
    sum1 = (A&1).sum()
    ans += sum1*(N-sum1) * 2**i
    #ans %= Large
    A>>=1 # A = A>>1とする
print(ans%Large)

Submission status: Wrong Answer

Solution code:
##かっこいい実装
import numpy as np
#mod = 10**9+7
#n = int(input())
#a = np.fromstring(input(), dtype = np.int64, sep = ' ')
#
#result = 0
#for i in range(60):
#    count_one = int((a&1).sum())
#    result += count_one*(n-count_one)*(2**i)
#    a >>= 1
#print(result%mod)

N = int(input())
A = np.fromstring(input(),dtype = np.int64, sep = ' ')
Large = 10**9 + 7
ans = 0
for i in range(60):
    sum1 = np.sum(A&1)
    ans += sum1*(N-sum1) * 2**i
    #ans %= Large
    A>>=1 # A = A>>1とする
print(ans%Large)

Submission status: Wrong Answer

Solution code:
##かっこいい実装
import numpy as np
#mod = 10**9+7
#n = int(input())
#a = np.fromstring(input(), dtype = np.int64, sep = ' ')
#
#result = 0
#for i in range(60):
#    count_one = int((a&1).sum())
#    result += count_one*(n-count_one)*(2**i)
#    a >>= 1
#print(result%mod)

N = int(input())
A = np.fromstring(input(),dtype = np.int64, sep = ' ')
Large = 10**9 + 7
ans = 0
for i in range(60):
    sum1 = np.sum(A&1)
    ans += sum1*(N-sum1) * pow(2,i)
    #ans %= Large
    A>>=1 # A = A>>1とする
print(ans%Large)

Submission status: Wrong Answer

Solution code:
##かっこいい実装
import numpy as np
#mod = 10**9+7
#n = int(input())
#a = np.fromstring(input(), dtype = np.int64, sep = ' ')
#
#result = 0
#for i in range(60):
#    count_one = int((a&1).sum())
#    result += count_one*(n-count_one)*(2**i)
#    a >>= 1
#print(result%mod)

N = int(input())
A = np.fromstring(input(),dtype = np.int64, sep = ' ')
Large = 10**9 + 7
ans = 0
for i in range(60):
    sum1 = np.sum(A&1)
    ans += sum1*(N-sum1) * pow(2,i,Large)
    ans %= Large
    A>>=1 # A = A>>1とする
print(ans)

Submission status: Wrong Answer

Solution code:
##かっこいい実装
import numpy as np
#mod = 10**9+7
#n = int(input())
#a = np.fromstring(input(), dtype = np.int64, sep = ' ')
#
#result = 0
#for i in range(60):
#    count_one = int((a&1).sum())
#    result += count_one*(n-count_one)*(2**i)
#    a >>= 1
#print(result%mod)

N = int(input())
A = np.fromstring(input(),dtype = np.int64, sep = ' ')
Large = 10**9 + 7
ans = 0
for i in range(60):
    sum1 = np.sum(A&1)
    ans += sum1*(N-sum1) * pow(2,i,Large)
    A>>=1 # A = A>>1とする
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np
import math
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 10**9 + 7
    n = I()
    a = np.array(LI())
    ans = 0
    for i in range(61):
        c0 = sum((a>>i)&1)
        c1 = n-c0
        ans += (c0*c1*2**i)%mod
    ans %= mod
    print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    mod=10**9+7
    n=int(readline())
    a=list(map(int,readline().split()))
    a=np.array(a,dtype=np.int64)

    b=np.array([((a>>i)&1).sum() for i in range(61)],dtype=np.int64)
    c=np.full(61,n,dtype=np.int64)-b
    d=b*c

    ans=0
    now=1
    for i in range(60):
        ans+=d[i]*now
        ans%=mod
        now*=2
        now%=mod

    print(ans)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=sorted(list(map(int,input().split())))
for i,x in enumerate(l):
  l[i]=format(x,'63b')
memo=[0]*63
for i in range(61):
  for j in range(n):
    if l[j][i]=='1':
      memo[-i-1]+=1
now=1
ans=0
mod=10**9+7
for x in memo:
  ans+=(now*x*(n-x))%mod
  now*=2
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = list(map(int,input().split()))
a = np.array(a,dtype=np.int64)
point = 0
mod = 10**9+7

b = [((a>>i)&1).sum() for i in range(61)]
c = [n-b[i] for i in range(61)]
d = [c[i]*b[i]%mod for i in range(61)]

point = 0
for i in range(61):
    point += (2**i)*d[i]%mod

point %= mod

print(point)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = list(map(int,input().split()))
a = np.array(a,dtype=np.int64)
point = 0
mod = 10**9+7

b = [((a>>i)&1).sum() for i in range(61)]
c = [n-b[i] for i in range(61)]

point = 0

for i in range(61):
    point += 2**i*(b[i]*c[i])%mod

print(point%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = list(map(int,input().split()))
a = np.array(a,dtype=np.int64)
point = 0
mod = 10**9+7

b = [((a>>i)&1).sum() for i in range(61)]
c = [n-b[i] for i in range(61)]

point = 0

for i in range(61):
    point += 2**i*b[i]*c[i]%mod

print(point%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(tuple(map(int,input().split())),np.int64)

ans = 0
mod = int(1e9+7)
for i in range(61):
    tmp = (A>>i)&1
    tmp = np.sum(tmp[tmp>0])
    ans += (N-tmp)*tmp*pow(2,i,mod)
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(tuple(map(int,input().split())),np.int64)

ans = 0
mod = int(1e9+7)
for i in range(61):
    tmp = np.sum((A>>i)&1)
    ans += (N-tmp)*tmp*pow(2,i,mod)
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = 0
mod = int(1e9+7)
for i in range(61):
    tmp = np.sum((A>>i)&1)
    ans += (N-tmp)*tmp*pow(2,i,mod)
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


import numpy as np


def main():
    n = gete(int)
    a = np.array(list(geta(int)), dtype='int64')
    a.sort()
    mod = 10**9 + 7
    ans = 0

    base = 1
    while a[-1] > 0:
        ones = (a & 1).sum()
        ans += ones * (n - ones) * base
        ans %= mod
        a = a >> 1
        base = (base * 2) % mod

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


import numpy as np


def main():
    n = gete(int)
    a = np.array(list(geta(int)), dtype='int64')
    a.sort()
    mod = 10**9 + 7
    ans = 0

    base = 1
    while a[-1] > 0:
        b = a & 1
        ones = b.sum()
        ans += ones * (n - ones) * base
        ans %= mod
        a = a >> 1
        base = base * 2 % mod

    print(ans % mod)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


import numpy as np


def main():
    n = gete(int)
    a = np.array(list(geta(int)))
    a.sort()
    mod = 10**9 + 7
    ans = 0

    base = 1
    while a[-1] > 0:
        b = a & 1
        ones = b.sum()
        ans += ones * (n - ones) * base
        ans %= mod
        a = a >> 1
        base = base * 2 % mod

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
mod = 1000000007
n = int(input())
a = list(map(lambda x: format(int(x), 'b'), input().split()))

cnt = [0] * 65

for i in range(n):
  a_len = len(a[i])
  for j in range(a_len):
    if a[i][j]  == '1':
      cnt[a_len-j-1] += 1
      
ans = 0
for i in range(len(cnt)-1, -1, -1):
  ans *= 2
  ans %= mod
  ans += cnt[i] * (n-cnt[i])
  
print(ans)

Submission status: Wrong Answer

Solution code:
mod = 1000000007
n = int(input())
a = list(map(lambda x: format(int(x), 'b'), input().split()))

cnt = [0] * 65

for i in range(n):
  for j in range(len(a[i])):
    if a[i][j]  == '1':
      cnt[len(a[i])-j-1] += 1
      
ans = 0
for i in range(len(cnt)-1, -1, -1):
  ans *= 2
  ans %= mod
  ans += cnt[i] * (n-cnt[i])
    
print(ans)

Submission status: Wrong Answer

Solution code:
# 0がX個、1がY個ある(ただしX+Y=N)とき、Xorの組み合わせ自体は N*(N-1)//2 通りある。
# しかし、それらの和をとることを考えてみた時
# (0,0)と(1,1)を選んだ場合はそのXORは0になることに注意すると、(0,1)の組み合わせの個数だけ数えれば良い。
# これは、たとえば　〇〇〇●●●●(X=3,Y=4)から〇と●を選ぶ組み合わせは何個あるか、という問いと同じことなので
# Nの値には依存することはなく、単純にX*Y通りとなる。
# よって
# ΣΣ A_i Xor A_j = X*Y
# この処理によって、O(N^2)が、O(N)(=Aの各数字を一通り調べる)に減らせる。
# これを各ケタについて計算し、合計すれば良い。
# ケタ数が60まで定まっているので 計算量は O(Nlog(max(A)))≦ O(N*60)
# あるケタのbitを取り出すには ビットシフト「>>」でずらして下1ケタだけを見ると便利。


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

ans=0
for k in range(60):
    cnt_z=0
    cnt_o=0
    #print(A)
    for i in range(N):
        s=A[i]%2
        if s==0:
            cnt_z +=1
        else:
            cnt_o +=1
        A[i] >>= 1
    ans += ((2**k)*cnt_z*cnt_o)%p
       
print(ans)

Submission status: Wrong Answer

Solution code:
# 0がX個、1がY個ある(ただしX+Y=N)とき、Xorの組み合わせ自体は N*(N-1)//2 通りある。
# しかし、それらの和をとることを考えてみた時
# (0,0)と(1,1)を選んだ場合はそのXORは0になることに注意すると、(0,1)の組み合わせの個数だけ数えれば良い。
# これは、たとえば　〇〇〇●●●●(X=3,Y=4)から〇と●を選ぶ組み合わせは何個あるか、という問いと同じことなので
# Nの値には依存することはなく、単純にX*Y通りとなる。
# よって
# ΣΣ A_i Xor A_j = X*Y
# この処理によって、O(N^2)が、O(N)(=Aの各数字を一通り調べる)に減らせる。
# これを各ケタについて計算し、合計すれば良い。
# ケタ数が60まで定まっているので 計算量は O(Nlog(max(A)))≦ O(N*60)
# あるケタのbitを取り出すには ビットシフト「>>」でずらして下1ケタだけを見ると便利。


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

ans=0
for k in range(60):
    cnt_z=0
    cnt_o=0
    for i in range(N):
        s=A[i]%(2**(k+1))
        if s==0:
            cnt_z +=1
        else:
            cnt_o +=1
        A[i] >>= 1
    ans += ((2**k)*cnt_z*cnt_o)%p
       
print(ans%p)

Submission status: Wrong Answer

Solution code:
# 0がX個、1がY個ある(ただしX+Y=N)とき、Xorの組み合わせ自体は N*(N-1)//2 通りある。
# しかし、それらの和をとることを考えてみた時
# (0,0)と(1,1)を選んだ場合はそのXORは0になることに注意すると、(0,1)の組み合わせの個数だけ数えれば良い。
# これは、たとえば　〇〇〇●●●●(X=3,Y=4)から〇と●を選ぶ組み合わせは何個あるか、という問いと同じことなので
# Nの値には依存することはなく、単純にX*Y通りとなる。
# よって
# ΣΣ A_i Xor A_j = X*Y
# この処理によって、O(N^2)が、O(N)(=Aの各数字を一通り調べる)に減らせる。
# これを各ケタについて計算し、合計すれば良い。
# ケタ数が60まで定まっているので 計算量は O(Nlog(max(A)))≦ O(N*60)
# あるケタのbitを取り出すには ビットシフト「>>」でずらして下1ケタだけを見ると便利。


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

ans=0
for k in range(60):
    cnt_z=0
    cnt_o=0
    for i in range(N):
        s=A[i]%(2**(k+1))
        if s==0:
            cnt_z +=1
        else:
            cnt_o +=1
        A[i] >>= 1
    ans += (2**k)*cnt_z*cnt_o
       
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(lambda x: format(int(x), '060b'), input().split(' ')))
mod = 10 ** 9
zero = [N]*60
one = [N]*60
ans = 0
cnt = 0
for i in A:
    cnt = max(cnt, len(i))
    for n, j in enumerate(i[::-1]):
        if int(j):
            zero[n] -= 1
        else:
            one[n] -= 1
for n, x in enumerate(zip(zero, one)):
    ans += pow(2,n,mod) * x[0]* x[1] % mod
    ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split(' '))))
mod = 10 ** 9 + 7
ans = 0
for n, i in enumerate(A[:-1]):
    ans += sum((A[n:] ^ i)) % mod
    ans %= mod
print(ans)

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 = ((aa&1).sum())//1
        ans += (cnt1*(n-cnt1)*(2**i))%MOD
        aa >>= 1
    print(ans%MOD)

if __name__ == '__main__':
    main()

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 = (aa&1).sum()
        ans += cnt1*(n-cnt1)*(2**i)
        aa >>= 1
    print(ans%MOD)

if __name__ == '__main__':
    main()