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:
# An efficient Python3 program to compute
# sum of bitwise OR of all pair

# Returns sum of bitwise OR
# of all pairs
def sumXOR( arr,  n):
    s = 0
    for i in range(0, 60):
        #  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
        s = (s + idsum)%(1000000007);
    return s



# driver function
s = 0
n = int(input())
arr = [int(i) for i in input().split()]
s = sumXOR(arr, n);
print(s)

Submission status: Wrong Answer

Solution code:
def sumXOR( arr,  n): 
  sum = 0
  for i in range(0, 60): 
    #  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 = [int(i) for i in input().split()]
# driver function  
sum = 0
sum = sumXOR(arr, n); 
print (int(sum % (1000000007)))

Submission status: Wrong Answer

Solution code:
#D
import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())),dtype=np.int64)
ans=0
for i in range(N-1):
    B=np.full(len(A)-i-1,A[i],dtype=np.int64)
    C=np.bitwise_xor.reduce([A[i+1:],B])
    ans+=np.sum(C)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int64)

X = (1 << np.arange(60, dtype=np.int64)) & A.reshape(-1,1)
B = np.sum(X != 0, axis=0)


total = 0

for i,count in enumerate(B):
  total += count * (N - count) * (1 << i)

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N = int(input())
A = input().split()

xor = 0

for i in range(N-1):
    #left = set(map(int, A[i] * (N-i)))
    left = [int(A[i])]
    right = list((map(int, A[i+1:])))
    xor +=sum(np.bitwise_xor(left, right))
    
print(xor%(10**9+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
cnt = 0
lst = list(map(int, input().split()))
for i in range(1, N-1):
    x = lst[i] ^ lst[i+1]
    cnt += x%(10**9 + 7)
print(cnt)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False


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
        _sum %= MOD

    return _sum


def main():
    N = I()
    A = list(MI())
    print(sumXOR(A, N))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
b = [0]*60
for i in range(n):
    for j in range(a[i].bit_length()):
        if (a[i] >> j) & 1:
            b[j] += 1
ans = 0
tmp = 0
for i in range(59):
    r = n-b[i]
    ans += b[i]*r*(2**tmp)
    ans %= mod
    tmp += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
A_list = list(map(int,input().split()))
sum_xor = []
append = sum_xor.append

for i in itertools.combinations(A_list, 2):
    a,b = i
    append(a^b)

print(sum(sum_xor))

Submission status: Wrong Answer

Solution code:
# D - Xor Sum 4
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i,N):
        ans += int(A[i]^A[j]) % 1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N = int(input())
A = input().split()

xor = 0

for i in range(N-1):
    #left = set(map(int, A[i] * (N-i)))
    left = [int(A[i])]
    right = list((map(int, A[i+1:])))
    print(left)
    print(right)
    xor +=sum(np.bitwise_xor(left, right))
    
print(xor%(10**9+7))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
N = int(input())
A = list(map(int,input().split()))
sm = 0
MOD = 1000000007
def sumXOR(arr,  n):       
    sum = 0
    for i in range(0, 60): 
        #  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)%MOD
                  
            else: 
                oc = (oc + 1)%MOD
            arr[j] = int(arr[j] / 2) 
          
           
        # calculating individual bit sum  
        idsum = (oc * zc * (1 << i) ) % MOD
   
        # final sum     
        sum = (sum + idsum)%MOD;  
      
    return sum % MOD

sm = sumXOR(A,N)
print (sm)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod = 10**9+7
n = int(input())
a = [int(x) for x in input().split()]
a = np.array(a)
count = 0


for i in range(0,n-1):
    f = np.bitwise_xor(a,a[i])
    count+=sum(f)/2

count = count%(mod)
print(int(count))

Submission status: Wrong Answer

Solution code:
def xor(l1=[]):
  
  s2=0
  n=len(l1)

  for i in range(64):
    zero=0
    for j in range(n):
      if l1[j]%2==0:
        zero+=1
      l1[j]=l1[j]//2

    #print(one)
    #print(zero)
    #print(2**i)
    s2+=(n-zero)*zero*(2**i)
    
  return s2

n = int(input())
arr = input()   # takes the whole line of n numbers
l = list(map(int,arr.split(' ')))
val=xor(l)
mod=1e9+7
val=val%mod
print(int(val))

Submission status: Wrong Answer

Solution code:
input1 = int(input())
input2 = input().split(" ")
input2loop = enumerate(input2)
for i, value in input2loop:
    input2[i] = int(value)


result = 0
temp = []
for index, i in enumerate(input2):
    temp = input2[index+1:]
    for j in temp:
        result += i ^ j
print(result)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(x) for x in input().split()]

sum=0

for i in range(N):
    for j in range(i+1,N):
        sum+=A[i]^A[j]

print(sum/(1000000000+7))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
N = int(input())
A = list(map(int,input().split()))
sm = 0
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)%MOD
                  
            else: 
                oc = (oc + 1)%MOD
            arr[j] = int(arr[j] / 2) 
          
           
        # calculating individual bit sum  
        idsum = (oc * zc * (1 << i) ) % MOD
   
        # final sum     
        sum = (sum + idsum)%MOD;  
      
    return sum % MOD

sm = sumXOR(A,N)
print (sm)

Submission status: Wrong Answer

Solution code:
MOD=10**9+7
n=int(input())
d=list(map(int,input().split()))
m=1
a=0
d=set(d)
d=list(d)
for j in range(len(d)):
  for i in range(m,len(d)):
    a+=int(bin(d[j]^d[i]),2)
  m+=1
print(a%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod = 10**9+7
n = int(input())
a = [int(x) for x in input().split()]
a = np.array(a)
count = 0


for i in range(0,n):
    f = np.bitwise_xor(a,a[i])
    count+=sum(f)

count = int(count/2)
count = count%(mod)
print(count)

Submission status: Wrong Answer

Solution code:
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 = [int(i) for i in input().split()]
# driver function  
sum = 0
sum = sumXOR(arr, n); 
print (int(sum % (1000000007)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0] * 60
    for i in A:
        for j in range(60):
            if i & (1 << j):
                B[j] += 1
    print(B[:5])
    r = 0
    for ii, i in enumerate(A[:-1]):
        for j in range(60):
            if i & (1 << j):
                B[j] -= 1
            if i & (1 << j):
                r += (1 << j) * (N - ii - 1 - B[j])
            else:
                r += (1 << j) * B[j]
            r = r % MOD
    print(r)

main()

Submission status: Wrong Answer

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

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] = arr[j] / 2 
          
           
        # calculating individual bit sum  
        idsum = (oc * zc * ((1 << i)))
   
        # final sum     
        sum = (sum + idsum)
      
    return sum
  
  
  
  
print(sumXOR(A, N)  % 1000000007)

Submission status: Wrong Answer

Solution code:
n = int(input())
a=list(map(int,input().split()))
print(a)
sum1 = 0
length = len(a)-1
for i in range(length):
    p = a.pop(0)
    b=list(map(lambda x:x^p,a))
    sum1 += sum(b)
print(sum1%(10**9+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int,input().split()))
ans = 0
arr.sort()
for i in range(N):
    for j in range(i,N):
        ans += arr[i]^arr[j]
print(ans)

Submission status: Wrong Answer

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

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))) % 1000000007
   
        # final sum     
        sum = (sum + idsum)
      
    return sum
  
  
  
  
print(sumXOR(A, N)  % 1000000007)

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7


def read_valus():
    return map(int, input().split())


def read_list():
    return list(read_valus())


def read_lists(N):
    return [read_list() for n in range(N)]


def p(N, a):
    return (a * (N - a)) % mod


def main():
    N = int(input())
    A = read_list()

    num = [0] * 65
    for a in A:
        b = format(a, "065b")
        for i in range(65):
            num[i] += int(b[i])

    res = 0
    for i in range(65):
        if num[i] == 0:
            continue

        res = (res + (pow(2, i, mod) * p(N, num[i])) % mod) % mod

    print(res % mod)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
ls = []
ls2 = []
ans = 0

for i in range(n-1):
    for j in range(i,n):
        p = a[i]^a[j]
        ls.append([a[i],a[j]])
        ls2.append(p)
        if [a[i],a[j]] in ls:
            ans+=ls2[ls.index([a[i],a[j]])]
        elif [a[j],a[i]] in ls:
            ans+=ls2[ls.index([a[j],a[i]])]
        else:
            ans+=p
        
print(ans%10**9)

Submission status: Wrong Answer

Solution code:
def sumXOR( arr,  n): 
  sum = 0
  for i in range(0, 32): 
    #  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 = [int(i) for i in input().split()]
# driver function  
sum = 0
sum = sumXOR(arr, n); 
print (int(sum % (10**9+7)))

Submission status: Wrong Answer

Solution code:
MOD =10**9+7
total = 0
n=int(input())
a_list = list(map(int,input().split()))
for i in range(n-1):
    for j in range(i,n):
        total = ((total+(a_list[i]^a_list[j])%MOD))
print(total)

Submission status: Wrong Answer

Solution code:
n = int(input()) 
L = list(map(int, input().split()))
out = 0
for i in L:
  for j in range(L.index(i)+1, n):
    if i != L[j]:
      out += (i ^ L[j]) % (10**9 +7)
    
print(out%(10**9+7))

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
A_list = list(map(int,input().split()))
sum_xor = 0

for i in itertools.combinations(A_list, 2):
    a,b = i
    sum_xor += a^b

print(sum_xor)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = [int(i) for i in input().split()]
divide = 10 ** 9 + 7

inf=float("inf")
dp=[[inf for i in range(n+1)] for j in range(n+1)]

sum = 0
for i in range(n):
    for j in range(i+1, n):
        if dp[i][j] != inf or dp[j][i] != inf:
            sum += dp[i][j]
            print('yes')
        else:
            val =  a_list[i] ^ a_list[j]
            dp[i][j] = val
            dp[j][i] = val
            sum += val

print(sum % divide)
print(dp)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    a_s = LI()
    kaizyo = [1]
    kaizyo_append = kaizyo.append
    keta = [0 for i in range(60)]
    ans = 0
    for i in range(60):
        kaizyo_append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for i, v in enumerate(format(i, 'b')):
            keta[i] += int(v)
    for i, v in enumerate(keta):
        c = v * (n-v) % MOD
        ans += c * kaizyo[i]
        ans = ans % MOD
        # print(ans, c, kaizyo[i])

    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = input()
nums = list(map(int, input().split()))
sum = 0
for index, i in enumerate(nums):
    for j in nums[index+1:]:
        sum += i^j
print(int(sum % (1e+9 + 7)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
MOD = 10**9 + 7

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

count_list = [0] * 60
for i in inputs:
    tmp = bin(i)[2:].zfill(60)
#    for i in range(60):
#        count_list[i] += int(tmp[i])

result = 0
for i in range(60):
    keta_result = count_list[i] * (n - count_list[i])
    #print("keta_result="+str(keta_result)+" i="+str(i))
    result += keta_result * (2 ** (60 - 1 - i))
#print(count_list)
print(result % MOD)

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7
n = int(input())
s = 0
a = list(map(int, input().split()))
m = 64
def calc_sum(arr,  n, m): 
    s = 0
    for i in range(0, m): 
        zc = 0
        oc = 0
        idsum = 0
        for j in range(0, n): 
            if (arr[j] % 2 == 0): 
                zc += 1
            else: 
                oc += 1
            arr[j] = int(arr[j] / 2) 
        idsum = oc * zc * (1 << i) 
        s += idsum
    return s
  
print(calc_sum(a, len(a), m)%MOD)

Submission status: Wrong Answer

Solution code:
def sumXOR( arr,  n):       
    MOD = 10 ** 9 + 7
    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 * zc * (1 << i)    
        sum = (sum + idsum) % MOD;        
    return sum

n = int(input())
A = list(map(int, input().split()))
sum = 0
sum = sumXOR(A, n); 
print(sum)

Submission status: Wrong Answer

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

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) % 1000000007)) % 1000000007
   
        # final sum     
        sum = (sum + idsum) % 1000000007
      
    return sum
  
  
  
  
print(sumXOR(A, N)  % 1000000007)

Submission status: Wrong Answer

Solution code:
N = int(input())
n_list = list(map(int, input().split()))
n_sum = 0
xor_list = []
for i in range(N):
    for j in range(0, i):
        xor_list.append(n_list[i] ^ n_list[j])
print(sum(xor_list))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a_2 = []
for i in range(n):
  a_2.append(int(format(a[i],'b')))
total = 0
for i in range(n):
  for j in range(n):
    if i != j:
      t = str(a_2[i] + a_2[j])
      t_10 = int(t.replace('2','0'), 2)
      total += t_10
print((total/2) % (10**9+7))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=[0]*64
ans=0
for i in range(62):
  c[i]=sum([1 if (j>>i)&1==1 else 0 for j in a])
  ans+=c[i]*(n-c[i])*2**i
print(ans)

Submission status: Wrong Answer

Solution code:
def solve(a_s) -> int:
  def get_ret_from_xs(xs) -> int:
    ret = 0
    for i, x in enumerate(xs):
      ret += 2**i * (x % 2)
      ret %= 10**9 + 7
    return ret

  # zeros = [1, 1] + [0] * 58  # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  # ones = [2, 2] + [0] * 58 # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  zeros = [0] * 60
  ones = [0] * 60

  for a in a_s:
    for i in range(len(zeros)):
      a_bin = format(a, '060b')
      a_i_digit_from_right = a_bin[60 - i - 1]
      if a_i_digit_from_right == '0':
        zeros[i] += 1
      else:
        ones[i] += 1

  xs = []

  for i in range(len(zeros)):
    x_i = (zeros[i] * ones[i]) % (10**9 + 7)
    if i >= 1:
      x_i += xs[i - 1] // 2
    xs.append(x_i)

  #xs = [2, 3, 1]
  return get_ret_from_xs(xs)


n = int(input().strip())
a_s = [int(s) for s in input().split()]

#a_s = [1, 2, 3]
#a_s = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a_s = [3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

print(solve(a_s))

Submission status: Wrong Answer

Solution code:
mod = int(1e9 + 7)
N = int(input())
A = list(map(int, input().split()))
S = 0
j = 0
while A != [0 for i in range(N)]:
  m = 0
  n = 0
  for i in range(N):
    if A[i] % 2 == 1:
      m += 1
    else:
      n += 1
    A[i] //= 2
  S += (((m * n) * (2 ** j)) % mod)
  j += 1
print(S)

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = list(map(int, input().split()))
ans = 0

print(ai)

for i in range(n-1):
  for j in range(i+1, n):
    ans += ai[i] ^ ai[j]
  ans = ans % (pow(10,9)+7)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod = 10**9+7
n = int(input())
a = [int(x) for x in input().split()]
a = np.array(a)
count = 0


for i in range(0,n-1):
    for j in range(i+1,n):
        count+=np.bitwise_xor(a[i] , a[j])

count = count%(mod)
print(count)

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(n-1):
    for j in range(i,n):
        ans+=a[i]^a[j]%mod
print(ans)

Submission status: Wrong Answer

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

# print(bin(A[0]))
# print(format(A[0], "b"))

result = 0

for i in range(N):
    for j in range(N):
        # ai= format(A[i], "b")
        # aj= format(A[j], "b")
        ai = A[i]
        aj = A[j]
        xor = ai^aj
        # print(xor)
        # print(ai,aj,format(xor,"b"))
        result += int(xor)

print(int(result/2)%(10**9+7))

def xor(ai, aj): #str
    pass

Submission status: Wrong Answer

Solution code:
N = input()
nums = list(map(int, input().split()))
sum = 0
for i in nums:
    for j in nums[i:]:
      sum += i^j
print(int(sum%(1e+9 + 7)))

Submission status: Wrong Answer

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

for i in range(len(A)-1):
    for j in range(i+1, len(A)):
        ans += (A[i] ^ A[j])


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()))
o = [[0] * (n + 1) for _ in range(80)]
x = [[0] * (n + 1) for _ in range(80)]
for b in range(80):
    for i in range(n):
        o[b][i + 1] += o[b][i]
        x[b][i + 1] += x[b][i]
        if a[i] >> b & 1 == 1:
            o[b][i + 1] += 1
        else:
            x[b][i + 1] += 1
li = []
nxt = 0
for b in range(80):
    c = 0
    for i in range(n):
        if a[i] >> b & 1 == 1:
            c += x[b][i]
        else:
            c += o[b][i]
    li.append((nxt + c) % 2)
    nxt = (nxt + c) // 2
ans = 0
for b in range(80)[::-1]:
    ans *= 2
    ans += li[b]
    ans %= MOD
print(ans)

Submission status: Wrong Answer

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

for i in range(N):
    for j in range(i+1, N):
        count += A[i] ^ A[j]
        
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    SUM = sum(A)
    B = {}
    for a in A:
        for i, b in enumerate(bin(a)[2:][::-1]):
            B[i] = B.get(i,0) + int(b)
    res = (N-1)*SUM + sum(2**i*(B[i]*(N+1-2*B[i])) for i in B)
    return str(res//2)

if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
N = input()
nums = list(map(int, input().split()))
sum = 0
for i in nums:
    for j in nums[i:]:
      sum += i^j
print(sum%1000000007)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
mod=1000000007
goukei=0
for i in s:
  for j in s[s.index(i)+1:]:
    goukei+=(i^j)
kotae=goukei%mod
print(kotae)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
o = [[0] * (n + 1) for _ in range(60)]
x = [[0] * (n + 1) for _ in range(60)]
for b in range(60):
    for i in range(n):
        o[b][i + 1] += o[b][i]
        x[b][i + 1] += x[b][i]
        if a[i] >> b & 1 == 1:
            o[b][i + 1] += 1
        else:
            x[b][i + 1] += 1
li = []
nxt = 0
for b in range(60):
    c = 0
    for i in range(n):
        if a[i] >> b & 1 == 1:
            c += x[b][i]
        else:
            c += o[b][i]
    li.append((nxt + c) % 2)
    nxt = (nxt + c) // 2
ans = 0
for b in range(60)[::-1]:
    ans *= 2
    ans += li[b]
    ans %= MOD
print(ans)

Submission status: Wrong Answer

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

# print(bin(A[0]))
# print(format(A[0], "b"))

result = 0

for i in range(N):
    for j in range(N):
        # ai= format(A[i], "b")
        # aj= format(A[j], "b")
        ai = A[i]
        aj = A[j]
        xor = ai^aj
        # print(xor)
        # print(ai,aj,format(xor,"b"))
        result += int(xor)

print(int(result/2))

def xor(ai, aj): #str
    pass

Submission status: Wrong Answer

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

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

result = num % (10^9 + 7)
print(result)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
A_list = list(map(int,input().split()))
sum_xor = 0

for i in itertools.product(A_list, repeat=2):
    a,b = i
    sum_xor += a^b

for m in range(N):
    sum_xor -= A_list[m]^A_list[m]

print(int(sum_xor/2))

Submission status: Wrong Answer

Solution code:
# An efficient Python3 program to compute 
# sum of bitwise OR of all pair 

# Returns sum of bitwise OR 
# of all pairs 
def sumXOR( arr, n): 
	
	sum = 0
	for i in range(0, 61): 

		# 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



# driver function 
sum = 0
#arr = [ 5, 9, 7, 6 ] 
n = int(input())
arr = list(map(int,input().split()))
#print(arr[0])
sum = sumXOR(arr, n)%1000000007; 
print (sum)

Submission status: Wrong Answer

Solution code:
int(input())
lis = list(int(i) for i in input().split())  
sum = 0
for i in range(len(lis)):
  for j in range(len(lis)):
    sum += lis[i] ^ lis[j]
        
print(int(sum/2) % (1000000000 + 7))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)

n=int(input())
a=list(map(int, input().split()))
p=0
for i in range(n-1):
    p=p+a[i]^a[i+1]
print(p%1000000007)

Submission status: Wrong Answer

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

num = 0
for i in range(N - 1):
    if N - i > 0:
        for j in range(N - i):
            num += int(bin(A[i] ^ A[j + i]), 2)
    else:
        break

result = num % (10^9 + 7)
print(result)

Submission status: Wrong Answer

Solution code:
import itertools
def main():
    N = int(input())
    A = list(map(int, input().split()))
    sum = 0
    for i in itertools.combinations(A, 2):
        sum += i[0]^i[1]
    print(sum)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

n = (1e9)+7
sum = 0
for i in range(N-1):
    for j in range(i+1, N):
        sum += (A[i] ^ A[j]) % n
       
print(int(sum) % n)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    maxa = max(a)
    k = 0
    while 2 ** k <= maxa:
        k += 1
    mod = 10 ** 9 + 7
    mo2 = [1]
    for _ in range(k):
        mo2.append(mo2[-1] * 2)

    p = [[0, 0] for i in range(k)]
    for sa in a:
        for j in range(k):
            if mo2[j] & sa != 0:
                p[j][1] += 1
            else:
                p[j][0] += 1
    res = 0
    for sa in a:
        for j in range(k):
            if mo2[j] & sa != 0:
                res += mo2[j] * p[j][0]
            else:
                res += mo2[j] * p[j][1]
            res %= mod
    print(res // 2)


main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
a = sorted(a)
ans=0
for i in range(n-1):
    t = 0
    p = 0
    for j in range(i,n):
        if p==1 and a[j-1]==a[j]:
            ans+=t
        elif a[i]==a[j]:
            continue
        else:
            ans+=a[i]^a[j]
            t=a[i]^a[j]
            p+=1
        
print(ans%10**9)

Submission status: Wrong Answer

Solution code:
import sys

inf = float("inf")

# import random
# from collections import deque, Counter, OrderedDict,defaultdict
# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
# from math import ceil,floor,log,sqrt,factorial,pi,gcd
# from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right

def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

mod = 10**9+7

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 = get_array()
ans = sumXOR(Arr,n)
ans%=mod
print(ans)