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

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
a = na()

ans = 0
for i in range(61):
	z, o = [0] * 2
	for j in range(n):
		if a[j] & (1 << i):
			o += 1
		else:
			z += 1
	ans += z * o * (2 ** i)

print(ans)

Submission status: Wrong Answer

Solution code:

import heapq
import collections
N =  int(input())
nums = list(map(int,input().split(" ")))
keta = [0 for _ in range(61)]
# ある桁の1の出現回数
# keta[k] → 2**k の桁
jijou = [1]
MOD = 10 ** 9 + 7
for i in range(60):
    temp = jijou[i] * 2
    temp%= MOD
    jijou.append(temp)

for num in nums:
    s = format(num,"b")
    l = len(s)
    for i in range(0,l):
        keta[i] += int(s[l - i - 1 ])
ans = 0
for j,num in  enumerate(nums[:-1]):
    s = format(num, "b")
    l = len(s)
    for i in range(0,61): #i →  2 ** i 乗 桁目に対応
        if l <= i:
            ans += (keta[i] * jijou[i]) % MOD
        else:
            if s[l - i - 1 ] == "0":
                ans += (keta[i] * jijou[i]) % MOD
            else:
#              (N - j + 1) - (keta[i] + 1 ) → 0が経っているところの個数
                ans += (( (N - j + 1) - (keta[i] + 1)  ) * ( jijou[i]) ) % MOD
                keta[i] -= 1


print(ans )

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

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

L = [0] * 60

for i in range(N):
	tmp = Base_10_to_n(A[i],2).rjust(60,"0")
	for j in range(60):
		if tmp[j] == "1":
			L[j] += 1

ans = 0
binary = 1
for i in range(60):
	ans += ((L[-(i+1)] * (N-L[-(i+1)])) % mod) * binary 
	ans %= mod
	binary *= 2
	binary %= mod

print(ans%mod)

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

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

L = [0] * 60

for i in range(N):
	tmp = Base_10_to_n(A[i],2).rjust(60,"0")
	for j in range(60):
		if tmp[j] == "1":
			L[j] += 1

ans = 0
binary = 1
for i in range(60):
	ans += (L[-(i+1)]%mod) * ((N-L[-(i+1)])%mod) * binary 
	ans %= mod
	binary *= 2
	binary %= mod

print(ans%mod)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())

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


aas = list(itertools.combinations(a,2))
m = len(aas)

x = 0
for i in range(m):
    x += ((aas[i][0] ^ aas[i][1]) % (10**7 + 9))
    x %= 10**7 + 9

print(x)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())

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


aas = list(itertools.combinations(a,2))
m = len(aas)

x = 0
for i in range(m):
    x += (aas[i][0] ^ aas[i][1])
    

print(x)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

MOD = 10^9+7
N = int(input())
A = [int(a) for a in input().split()]
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans = (ans + (A[i] ^ A[j])) % MOD
        
print(ans)

Submission status: Wrong Answer

Solution code:

MOD = 10 ** 9 + 7
n = int(input())
a = list(map(lambda x: format(int(x), '060b')[::-1], input().split()))

ans = 0
onecount = [0 for i in range(60)]
zerocount = [0 for i in range(60)]
for i in range(n):
    for j in range(60):
        if a[i][j] == '1':
            onecount[j] += 1
        else:
            zerocount[j] += 1

for i in range(60):
    ans += (2 ** i) * onecount[i] * zerocount[i]
print(ans)

Submission status: Wrong Answer

Solution code:
#python3
import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])
mod=int(1e9+7)
ans=0
for k in range(60):
  b = (a>>k)&1
  m = b.sum()
  ans += m*(n-m)*2**k
print(ans%mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
plus = sum([int(s) for s in input().split()])
minus = N - plus
 
print( (plus * minus) % (10**9 + 7) )

Submission status: Wrong Answer

Solution code:
#python3
#python3
import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])
MOD = int(1e9+7)
ans=0
for k in range(60):
  b=(a>>k)&1
  x=sum(b)
  ans+=x*(n-x)*2**k
print(ans%MOD)

Submission status: Wrong Answer

Solution code:
N = int(input())
C = {i:0 for i in range(60)}
A = input().split()
for i in range(N):
    a = bin(int(A[i]))[2:]
    n = len(a)
    for j in range(n):
        if a[j]=="1":
            C[n-1-j] += 1
cnt = 0
for i in range(60):
    if C[i]>0:
        cnt += C[i]*(N-C[i])*2**i
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
C = {i:0 for i in range(60)}
A = input().split()
for i in range(N):
    a = bin(int(A[i]))[2:]
    n = len(a)
    for j in range(n):
        if a[j]=="1":
            C[n-1-j] += 1
cnt = 0
for i in range(20):
    if C[i]>0:
        cnt += C[i]*(N-C[i])*2**i
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np 

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

A = np.array(A,np.int64)##Ai<2^60

ans = 0
mod = int(1e9+7)

for i in range(60):
    bottom_bit = (A>>i)&1 ##i回シフトしたときの最下位bit
    ones = sum(bottom_bit[bottom_bit==1])
    ##ans += (N-ones)*ones*(2**i) ##0の個数*1の個数*2^i個
    tmp = ones*(N-ones)
    for j in range(i):
        tmp *= 2 % mod
    ans += tmp

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,np.int64)##Ai<2^60

ans = 0
mod = int(1e9+7)

for i in range(60):
    bottom_bit = (A>>i)&1 ##i回シフトしたときの最下位bit
    ones = sum(bottom_bit[bottom_bit==1])
    ##ans += (N-ones)*ones*(2**i) ##0の個数*1の個数*2^i個
    tmp = 1
    for j in range(i):
        tmp *= 2 % mod
    ans += (N-ones)*ones*tmp % mod

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,np.int64)##Ai<2^60

ans = 0
mod = int(1e9+7)

for i in range(60):
    bottom_bit = (A>>i)&1 ##i回シフトしたときの最下位bit
    ones = sum(bottom_bit[bottom_bit==1])
    ans += (N-ones)*ones*(2**i) ##0の個数*1の個数*2^i個

print(ans%mod)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jan  4 21:05:55 2020

@author: USER
"""

A=list(map(int,input().split()))
a=max(A)
v=0
u=0
while v==0:
    if a<2**u:
        v=1
    else:
        u=u+1
u=u-1
e=0
for i in range(u+1):
     c=0
     d=0
     for s in range(len(A)):
        if A[s]//2**(u-i)==1:
            c=c+1
            A[s]=A[s]%2**(u-i)
        else:
            d=d+1
     e=e+c*d*2**(u-i)
print(e%(10**9+7))

Submission status: Wrong Answer

Solution code:
def xor(a,b):
    
    # aよりもbの方を長くする
    if len(b) < len(a):
        a,b = b,a
        
    # 長さを取っておく
    na = len(a)
    nb = len(b)
    
    # xor計算
    t = b[:nb-na] + "".join([ str(int(sa!=sb)) for sa,sb in zip(a,b[nb-na:]) ])
    
    return int(t,2)

n = int(input())
numbers = [bin(int(i))[2:] for i in input().split(" ")]

total = 0
for i in range(n):
    for j in range(i+1,n):
        total += xor(numbers[i],numbers[j])        
print(int(total%(1e9+7)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [format(i, '060b') for i in map(int, input().split())]
divide = 10 ** 9 + 7
ans = []

for i in range(60):
    bit_list = [b[59-i] for b in a]
    val = bit_list.count('0') * bit_list.count('1')
    ans.append((val * 2 ** i) % divide)

print(sum(ans))

Submission status: Wrong Answer

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

total = 0

for i in range(0, N):
    for j in range(i + 1, N):
        total += int((A_i[i] ^ A_i[j]) % (1.0e+9 + 7))


total %= int(1.0e+9 + 7)

print(total)

Submission status: Wrong Answer

Solution code:
import itertools


input()
nums = [int(i) for i in input().split(" ")]
longest = len(bin(max(nums))) - 2
nums_bin = [format(i, "b").zfill(longest) for i in nums]


result = 0
for i in range(1, longest+1):
    one = 0
    zero = 0
    for num_bin in nums_bin:
        if num_bin[-1*i] == "1":
            one += 1
        elif num_bin[-1*i] == "0":
            zero += 1
        else:
            raise Exception()
    print(i, zero, one)
    result += (2 ** (i-1)) * (one * zero)
print(nums_bin)
print(result % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
N = int(input())
numlist = input().split(' ') 
sum = 0

for i in range(N-1):
  for j in range(N-1):
    if i-j>0:
      continue    
    else:
      print(i, j)
      sum += int(numlist[i])^int(numlist[j+1])
    
print(int(sum % (10**9 + 7)))

Submission status: Wrong Answer

Solution code:
MOD = 1e9 + 7

n = int(input())
tot = 0

cnt = [0] * 64
a = list (map(int, input().split()))
          
for i in range (n) :
    foo = a[i]
    tot += foo
    tot %= MOD
    for mask in range (60):
        cnt[mask] += (a[i] >> mask) & 1

res = 0

for i in range (n):
    cur = a[i]
    tot -= cur
    res += tot
    res %= MOD
    for mask in range (60):
        cnt[mask] -= (a[i] >> mask) & 1
    for mask in range (60):
        if ((cur >> mask) & 1) :
            cnt_not_set = n - i - 1 - cnt[mask]
            cnt_set = cnt[mask]
            res += (1 << mask) * cnt_not_set
            res -= (1 << mask) * cnt_set
            
       
print(int(res))

Submission status: Wrong Answer

Solution code:
MOD = 1e9 + 7

n = int(input())
tot = 0

cnt = [0] * 64
a = list (map(int, input().split()))
          
for i in range (n) :
    foo = a[i]
    tot += foo
    tot %= MOD
    for mask in range (60):
        cnt[mask] += (a[i] >> mask) & 1

res = 0

for i in range (n):
    cur = a[i]
    tot -= cur
    res += tot
    res %= MOD
    for mask in range (60):
        cnt[mask] -= (a[i] >> mask) & 1
    for mask in range (60):
        if ((cur >> mask) & 1) :
            cnt_not_set = n - i - 1 - cnt[mask]
            cnt_set = cnt[mask]
            res += (1 << mask) * cnt_not_set
            res -= (1 << mask) * cnt_set
            
       
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
l = len( "{0:b}".format(max(A)) )
print("{0:b}".format(max(A)))
A = ["{0:b}".format(a) for a in A]

Submission status: Wrong Answer

Solution code:
# #bin()やformat(数字 ,"b")を使うとstr型になる
# #bin()とformat(数字 ,"#b")は同意

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

for i in range(N): A[i] = format(A[i], "#b") #ここで全て60ビットの二進数に変換

sum = 0
c0 = [0]*60
c1 = [0]*60
for i in range(N):
    #print(A[i])
    for j in range(60):
        if A[i][-(j+1)] == "0": #str型であることに注意！
            c0[j] += 1
        elif A[i][-(j+1)] == "1":
            c1[j] += 1
        else:
            break

#print(c0[0], c0[1], c0[2], c1[0], c1[1], c1[2])
for i in range(60):
    if c1[i] > 0:
        c0[i] = N - c1[i] 
    sum += (c0[i] * c1[i]) << i

print(sum)


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

# for i in range(N): A[i] = format(A[i], "060b") #ここで全て60ビットの二進数に変換

# mod = 10**9+7

# sum = 0
# for i in range(1,61):
#     count0 = 0
#     count1 = 0
#     for j in range(N):
#         if A[j][-i] == "0": #str型であることに注意！
#             count0 += 1
#         else:
#             count1 += 1 
#     sum += (count0 * count1) << (i-1) #左シフトだが，2**(i-1)でもOK (処理速度変わらない)
# print(sum%mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
count0 = [0 for i in range(60)]
count1 = [0 for i in range(60)]
for a in A:
    a_tmp = bin(a).replace("0b","")
    a_tmp = a_tmp.zfill(60)
    for i,b in enumerate(a_tmp):
        if b == "1":
            count1[i] += 1
        else:
            count0[i] += 1
cnt = 0
ans = 0
for c0,c1 in zip(count0[::-1],count1[::-1]):
    ans += c0*c1*(2**cnt)
    cnt += 1

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
D = [[0, 0] for _ in range(60)]

for a in A:
    for i in range(60):
        if (a >> i) & 1:
            D[i][1] += 1
        else:
            D[i][0] += 1

ans = 0
mod = 10 ** 9 + 7

for idx, d in enumerate(D):
    ans += (d[0] * d[1] * (1 << idx)) % mod

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    """"ここに今までのコード"""

n = int(input())
A = [int(a) for a in input().split()]
mod=10**9+7

ans=0
for i in range(60):
    l=sum([a%(2**i) for a in A])
    ans=(ans+l*(n-l)*(2**i))%mod
    

#ans=xor[0]
#for j in range(60-1):
#    ans=((2*ans)+xor[j+1])%mod
print(int(ans)) 

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    n = int(input())
    a = np.array(list(map(int, input().split())), dtype=np.int64)
    l1 = [0]*61
    mod = 10**9+7
    for cnt in range(61):
        b = a % 2
        l1[cnt] = np.sum(b)
        a = a // 2
    l0 = [n-i for i in l1]
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    n = int(input())
    a = np.array(list(map(int, input().split())))
    l1 = [0]*61
    mod = 10**9+7
    for cnt in range(61):
        b = a % 2
        l1[cnt] = np.sum(b)
        a = a // 2
    l0 = [n-i for i in l1]
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    n = int(input())
    a = np.array(list(map(int, input().split())))
    l1 = [0]*61
    mod = 10**9+7
    for cnt in range(61):
        l1[cnt] = np.sum(a%2)
        a = a // 2
    l0 = [n-i for i in l1]
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    n = int(input())
    a = np.array(list(map(int, input().split())), dtype=np.int64)
    l1 = np.zeros(61, dtype=np.int64)
    mod = 10**9+7
    for cnt in range(61):
        l1[cnt] = np.sum(a % 2)
        a = a//2
    l0 = n-l1
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    n = int(input())
    a = np.array(list(map(int, input().split())))
    l1 = np.zeros(61, dtype=np.int64)
    mod = 10**9+7
    for cnt in range(61):
        l1[cnt] = np.sum(a % 2)
        a = a//2
    l0 = n-l1
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
inf = int(1e9+7);
def sumXOR( arr,  n): 
  sum = 0
  for i in range(0, 61):  
    zc = 0
    oc = 0 
    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)  
    idsum = (((oc%inf) * (zc%inf))%inf * (1 << i)%inf)%inf
    sum = (sum + idsum)%inf
  return sum%inf
def solve():
  n = int(input())
  arr = list(map(int, input().split()))
  temp = sumXOR(arr, n)
  print(temp)
solve()

Submission status: Wrong Answer

Solution code:
inf = int(1e9+7);
def sumXOR( arr,  n): 
  sum = 0
  for i in range(0, 60):  
    zc = 0
    oc = 0 
    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)  
    idsum = ((oc%inf) * (zc%inf) * (1 << i)%inf)%inf
    sum = (sum + idsum)%inf
  return sum%inf
def solve():
  n = int(input())
  arr = list(map(int, input().split()))
  temp = sumXOR(arr, n)
  print(temp)
solve()

Submission status: Wrong Answer

Solution code:
inf = int(1e9+7);
def sumXOR( arr,  n): 
  sum = 0
  for i in range(0, 60):  
    zc = 0
    oc = 0 
    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)  
    idsum = oc * zc * (1 << i)     
    sum = (sum + idsum)%inf
  return sum
def solve():
  n = int(input())
  arr = list(map(int, input().split()))
  temp = sumXOR(arr, n)
  print(temp)
solve()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    n = int(input())
    a = list(map(int, input().split()))
    l1 = np.zeros(61)
    mod = 10**9+7
    powlist = [pow(2, i, mod) for i in range(61)]
    for i in a:
        cnt = 0
        k = 1
        while k <= i:
            if i & k == k:
                l1[cnt] += 1
            cnt += 1
            k *= 2
    l0 = n-l1
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(int(ans))


main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    n = int(input())
    a = list(map(int, input().split()))
    l1 = np.zeros(61)
    mod = 10**9+7
    powlist = [pow(2, i, mod) for i in range(61)]
    for i in a:
        cnt = 0
        k = 1
        while k <= i:
            if i & k == k:
                l1[cnt] += 1
            cnt += 1
            k *= 2
    l0 = n-l1
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    l1 = [0]*61
    for i in a:
        cnt = 0
        k = 1
        while k <= i:
            if i & k == k:
                l1[cnt] += 1
            cnt += 1
            k *= 2
    l0 = [n-i for i in l1]
    ans = 0
    mod = 10**9+7
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    n = int(input())
    a = list(map(int, input().split()))
    l1 = np.zeros(61)
    for i in a:
        cnt = 0
        k = 1
        while k <= i:
            if i & k == k:
                l1[cnt] += 1
            cnt += 1
            k *= 2
    l0 = n - l1
    ans = 0
    mod = 10**9+7
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(int(ans))


main()

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
A=list(map(int, input().split()))


bit= [[0]*60 for i in range(n)]
for i in range(n):
    a=A[i]
    j=1
    while a//2>0:
        if a%2==1:
            bit[i][60-j]=1
            j+=1
            a=a//2
        else:
            j+=1
            a=a//2
    bit[i][60-j]=1
      
xor=[0]*60
    
for j in range(60):
    l=0
    for i in range(n):
        l+=bit[i][j]
    xor[j]=l*(n-l)
    
L=10**9+7
ans=xor[0]
for j in range(60-1):
    ans=((2*ans)+xor[j+1])%L
print(ans)

Submission status: Wrong Answer

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

import numpy as np

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

k = [0] * 60

for j in range(60):
    l = a & 1
    k[j] = np.count_nonzero(l)
    a >>= 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1

Submission status: Wrong Answer

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

import numpy as np

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

k = [0] * 60

for j in range(60):
    l = (a >> j) & 1
    for m in l:
        k[j] += m

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

Submission status: Wrong Answer

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

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

k = [0] * 60

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

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

Submission status: Wrong Answer

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

n = int(input())
a = np.asarray(list(map(int, input().split())))
ans = 0
bit = 1
for i in range(60):
  n_one = np.sum(a & 1)
  ans += n_one * (n - n_one) * bit
  a >>= 1
  bit *= 2
  ans %= mod
  bit %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod = 1000000007

n = int(input())
a = np.asarray(list(map(int, input().split())))
ans = 0
bit = 1
for i in range(60):
  n_one = np.sum(a & 1)
  ans += n_one * (n - n_one) * bit
  a >>= 1
  bit *= 2
print(ans % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod = 1000000007

n = int(input())
a = np.asarray(list(map(int, input().split())))
ans = 0
bit = 1
for i in range(60):
  n_one = np.sum(a & 1)
  ans += n_one * (n - n_one) * pow(2, i, mod) 
  ans %= mod
  a >>= 1
  bit *= 2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod = 1000000007

n = int(input())
a = np.asarray(list(map(int, input().split())))
ans = 0
bit = 1
for i in range(60):
  n_one = np.sum(a & 1)
  ans += n_one * (n - n_one) * 2 ** i 
  ans %= mod
  a >>= 1
  bit *= 2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod = 1000000007

n = int(input())
a = np.asarray(list(map(int, input().split())))
ans = 0
bit = 1
for i in range(60):
  n_one = np.sum(a & 1)
  ans += n_one * (n - n_one) * bit
  ans %= mod
  a >>= 1
  bit *= 2
print(ans)

Submission status: Wrong Answer

Solution code:
import cmath
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7


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

    ans=0
    for b in range(60):
        c0=0
        c1=0
        for i in range(N):
            if a[i] & (1<<b):
                c1+=1
            else:
                c0+=1

        ans+=(1<<b)*c0*c1

    print(ans)


if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted([int(x) for x in input().split()])
sum_s = 0
for i in range(N):
    for j in range(i, N):
        if i == j:
            continue
        sum_s += A[i] ^ A[j]
        #print("A[i]={:d}, A[j]={:d} result={:d}".format(A[i], A[j], A[i] ^ A[j]))

print(sum_s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
#Aiを二進数として，各けたを見れば良い？1の個数*0の個数
 
ans =0
mod =pow(10,9)+7
 
#Aiは最大で2^60-1
Max = 61
 
 #i桁目を見る
for i in range(Max):
    count = 0#その桁での1の数
    for j in range(N):
        if(A[j]>>i & 1)==1:
            count+=1
    ans+=count*(N-count)*pow(2,i)
    ans = ans%mod
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
#Aiを二進数として，各けたを見れば良い？1の個数*0の個数
 
ans =0
mod =pow(10,9)+7
 
#Aiは最大で2^60-1
Max = 61
 
 #i桁目を見る
for i in range(Max):
    count = 0#その桁での1の数
    for j in range(N):
        if(A[j]>>i & 1)==1:
            count+=1
    ans+=count*(N-count)*pow(2,i)
    ans = ans%mod

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(n) for n in input().split(' ')]
s = 0
a,b=[0,0]
for i in range(N-1):
    for j in range(i, N):
        if A[i]==A[j]:
            a +=1
        else:
            b+=1
         
    
ans = (a*b) % (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
l = input()
l = list(map(int, l.split()))
l = np.array(l)

sum_xor = 0
for i in range(n):
  for j in range(i+1, n):
    sum_xor += l[i]^l[j]
    # sum_xor %= 10**9+7

print(sum_xor % (10**9+7))

Submission status: Wrong Answer

Solution code:
N=int(input())
a_l=[int(i) for i in input().split()]

def xor(i,j):
    l=max(len(str(format(i,'b'))),len(str(format(j,'b'))))
    i2=str(format(i,'b').zfill(l))
    j2=str(format(j,'b').zfill(l))
    ans=0
    for k in range(l):
        if i2[k]!=j2[k]:
            ans+=2**(l-k-1)
    return ans

sum1=0
j=1
for i in range(N-1):
    while j<N:
        sum1+=xor(a_l[i],a_l[j])
        j+=1
    j=i+2
print(sum1)

Submission status: Wrong Answer

Solution code:
N=int(input())
a_l=[int(i) for i in input().split()]

def xor(i,j):
    l=max(len(str(format(i,'b'))),len(str(format(j,'b'))))
    i2=str(format(i,'b').zfill(l))
    j2=str(format(j,'b').zfill(l))
    ans=0
    for k in range(l):
        if i2[k]!=j2[k]:
            ans+=2**(l-k-1)
    return ans

sum1=0
j=1
for i in range(N-1):
    while j<N:
        sum1+=xor(a_l[i],a_l[j])
        j+=1
    j=i+1
print(sum1)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.fromstring(input(),dtype=np.int64,sep=" ")

wa = 0
kazu = 10**9 + 7
for i in range(60):
    b = (a & 1).sum()
    wa = (wa + b*(n-b)*(1<<i)) % kazu
    a = a >> 1

print(wa)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.fromstring(input(),dtype=np.int64,sep=" ")

wa = 0
kazu = 10**9 + 7
for i in range(60):
    b = sum(a & 1)
    wa = (wa + b*(n-b)*(1<<i)) % kazu
    a = a >> 1

print(wa)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

wa = 0
kazu = 10**9 + 7
for i in range(60):
    b = sum(a & 1)
    wa = (wa + b*(n-b)*(1<<i)% kazu)
    a = a >> 1

print(wa % kazu)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

wa = 0
kazu = 10**9 + 7
for i in range(60):
    b = sum(a & 1)
    wa = (wa + b*(n-b)*(1<<i)) % kazu
    a = a >> 1

print(wa)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.fromstring(input(), dtype=np.int64, sep=' ')
print(A)
res = 0
for bit in range(60):
    c = int((A & 1).sum())
    res += c * (N - c) * (1 << bit)
    A >>= 1

print(res % 1000000007)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p = len(format(max(A), 'b'))
digit = ['0' + str(p) + 'b'] * N
S = list(map(format, A, digit))
X = np.array([[int(c) for c in s] for s in S])
#print(X)
r = np.sum(X, 0)
#print(r)
r = r * (N - r)
#print(r)

res = 0
for j in range(p):
  res += r[j] * (2 ** (p-1-j))

print(res % (10**9 + 7))

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 i in range(64):
    tmp = A & 1
    A >>= 1
    x = tmp.sum()
    x *= n - x
    ans += pow(2, i, mod) * x % mod

print(ans % mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
sum = 0
for i in range(1,N):
    for j in range(i+1,N+1):
        sum += A[i-1] ^ A[j-1]

print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
sum = 0
for i in range(1,N):
    for j in range(i+1,N+1):
        sum += A[i-1] ^ A[j-1]

print(sum%10**9+7)

Submission status: Wrong Answer

Solution code:
N = int(input())
num_list = list(map(int, input().split()))
 
length = N
amount = 0
for i in range(length-1):
  for j in range(i+1, length):
    num1 = num_list[i]
    num2 = num_list[j]
    bit_num1 = format(num1, "b")
    bit_num2 = format(num2, "b") 
    length_num1 = len(bit_num1)
    length_num2 = len(bit_num2)
    max_length = max(length_num1, length_num2)
    bit_num1 = bit_num1.zfill(max_length)
    bit_num2 = bit_num2.zfill(max_length)       
    num = ""
    for k in range(1, max_length+1):
      if int(bit_num1[-k]) + int(bit_num2[-k]) == 1:
        num = "1" + num
      else:
        num = "0" + num
    amount += int(num, 2) % (10**9 + 7)

print(amount)

Submission status: Wrong Answer

Solution code:
import math
import  numpy as np

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

na = np.array(a)

ans = 0
a_max = max(a)

if a_max==0:alog=1
else:alog = int(math.log2(a_max))+1
  
for i in range(alog):
    p = pow(2, i)
    cnt = sum([np.bitwise_and(na, p)==p])
    s = np.sum(cnt)
    ans += s * (N - s)*(2**i)%(10**9+7)

print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !

#def change_bin(data):
#    return format(data,"b").zfill(64)
#A_bin = list(map(change_bin, A))
    
N = int(input())
A = [int(N) for N in input().split()]
max_size = len(format(max(A),"b"))
A_bin = list(map(lambda x: format(x,"b").zfill(max_size), A))


result = 0
for i in range(max_size):
    zero = 0
    one = 0
    for j in A_bin:
        if j[i] == "0":
            zero += 1
        else:
            one += 1
    result += (2**(max_size-1-i) * zero * one )%1000000007

print(result)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !

def change_bin(data):
    return format(data,"b").zfill(64)
    
N = int(input())
A = [int(N) for N in input().split()]
A_bin = list(map(change_bin, A))

result = 0
for i in range(64):
    zero = 0
    one = 0
    for j in A_bin:
        if j[i] == "0":
            zero += 1
        else:
            one += 1
    result += 2**(63-i) * zero * one
print(result)
#print(result%1000000007)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !

def change_bin(data):
    return format(data,"b").zfill(64)
    
N = int(input())
A = [int(N) for N in input().split()]
A_bin = list(map(change_bin, A))

result = 0
for i in range(64):
    zero = 0
    one = 0
    for j in A_bin:
        if j[i] == "0":
            zero += 1
        else:
            one += 1
    result += 2**(63-i) * zero * one

#print(result%1000000007)

Submission status: Wrong Answer

Solution code:
from sys import stdin

input = stdin.readline

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

cnt = [0] * 65
ans = 0
p = 0
for x in a:
    for i in range(60):
        pos = (x >> i) & 1
        if pos:
            ans += pow(2, i, mod) * (p - cnt[i])
        else:
            ans += pow(2, i, mod) * cnt[i]
        # print(x, i, pos, ans, cnt[:3])
        ans %= mod
        cnt[i] += pos
        p += 1

print(ans % mod)