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:
N = int(input())
A = list(map(int, input().split()))
ans = 0
t = []
for i in range(60):
    for j in range(N):
        if A[j] >= 2 ** i:
            t.append((A[j]%(2**(i+1)))//(2**i))
    ans += (t.count(1) * (N-t.count(1))) * 2**i
    t = []
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

res = 0

for i in range(64):
    zc = 0
    oc = 0
    idsum = 0
    for j in range(0, n):
        if (l[j] % 2 == 0):
            zc += 1
        else:
            oc += 1
        l[j] = int(l[j] / 2)
    
    idsum = oc * zc * (1 << i)
    
    res += idsum

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

Submission status: Wrong Answer

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

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


ans = sum(ans)

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

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, 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



# 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:
N = int(input())
A = list(map(int, input().split())) 

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

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


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

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

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

Submission status: Wrong Answer

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

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, 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



# 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:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
sum = 0
list = []
for i in range(0,n-1):
    for j in range(i+1,n):
        list = np.append(list,a[i]^a[j])

ans = np.mod(np.sum(list),10**9+7)
print(int(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)))
    right = set(map(int, A[i:]))
    xor += (sum(list(left.symmetric_difference(right))))

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


# N = int(input())
# A = input().split()

# xor = 0
# for i in range(N-1):
#     for j in range(i+1, N):
#         xor += int(A[i]) ^ int(A[j])
# print(xor%(10**9+7))

Submission status: Wrong Answer

Solution code:
def sumXOR( arr,  n): 
    sum = 0
    for i in range(0, 64): 
        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;        
    return sum
  
def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = sumXOR(A, len(A))
    print(count%(10**9+7))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    num = input()
    num_list = list(map(int, input().split(" ")))
    result = sum([sum([num_list[i]^num_list[j] for j in range(i)]) for i in range(int(num))])
    if result > (10**9 + 7):
        print(1)
    else:
        print(result)
    # print(result%(10**9+7))    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def getXor(x, y): 
    return ((x | y) & (~x | ~y))

def determineResult(num_string):
  num_arr = num_string.split()
  count = 1
  result = 0
  for num in num_arr:
    for num2 in num_arr[count:]:
      result += getXor(int(num), int(num2))
    count += 1
  print(result)

if __name__ == "__main__":
    count = input()
    num_string = input()
    determineResult(num_string)

Submission status: Wrong Answer

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

sum_ = 0

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

print(sum_ % (10**9 + 6))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
sum = 0
list = []
for i in range(0,n-1):
    for j in range(i+1,n):
        list.append(a[i]^a[j])

ans = np.mod(np.sum(list),10**9+7)
print(ans)

Submission status: Wrong Answer

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

sum_ = 0

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

print(sum_ // (10**9 + 6))

Submission status: Wrong Answer

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

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:
a = int(input())
b=list(map(int,input().split()))
sum1=0
num = []
for i in range(a-1):
  num=[b[i]^b[j] for j in range(i+1,a)]
sum1=sum(num)
 
if sum1>=1000000007:
  sum1=sum1%1000000007

print(sum1)

Submission status: Wrong Answer

Solution code:
def getXor(x, y): 
    return ((x | y) & (~x | ~y))

def determineResult(num_string):
  num_arr = num_string.split()
  count = 1
  result = 0
  for num in num_arr:
    for num2 in num_arr[count:]:
      print("Num: " + num + " Num2: " + num2)
      result += getXor(int(num), int(num2))
    count += 1
  print(result)

if __name__ == "__main__":
    count = input()
    num_string = input()
    determineResult(num_string)

Submission status: Wrong Answer

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


def main():
    mod = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        a_sub = a[i+1:]
        a_sub_dict = Counter(a_sub)
        for j in a_sub_dict:
            ans += a_sub_dict[j] * np.bitwise_xor(a[i], j)
    print(ans % mod)


if __name__ == '__main__':
    main()

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(str(ai[i]) + " " + str(ai[j]) + "  = " + str(ai[i] ^ ai[j]))


print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]
A = np.array([a.copy() for _ in range(n)])
print((A ^ A.T).sum() % (10 ** 9 + 7) // 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def factorial( n) : 
    M = input()
    f = 1
  
    for i in range(1, n + 1):  
        f = f * i
    return f % M

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)):
    if i != j:
	    sum += lis[i] ^ lis[j]
        
#print(int(sum/2) % (1000000000 + 7))

Submission status: Wrong Answer

Solution code:
n=int(input())

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

s=0
for i in range(len(a)-1):
    for j in range(i,len(a)):
        s+=a[i]^a[j]

print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = (10 ** 9) + 7

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

print(res % l)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
keta=[0]*60
for i in range(n):
    for j in range(60):
        if (a[i]>>j)&1==1:
            keta[j]+=1
print(keta)
s=sum(a)
ans=0
for i in range(n):
    s-=a[i]
    j=0
    tmp2=a[i]
    while tmp2!=0:
        if tmp2%2==1:
            keta[j]-=1
            print(j,keta[j])
            ans+=(2**j)*((n-(i+1)-keta[j]*2))
        j+=1
        tmp2=tmp2//2
    ans+=s
    ans%=mod
    # print(ans,s)
    # print(keta)
print(ans%mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(n) for n in input().split()]
Aset = set(A)
m = (10**9+7)
o = {}
ans = []
for a in A:
    o.setdefault(a, 0)
    o[a] += 1
for i in range(len(Aset)-1):
    for j in range(i+1, len(Aset)):
        ans.append((A[i]^A[j])*o[A[i]]*o[A[j]])
print(sum(ans)/m)

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]
    keta = [0 for i in range(61)]
    ans = 0
    for i in range(61):
        kaizyo.append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for i, v in enumerate(bin(i)[:1:-1]):
            keta[i] += int(v)
    # print(kaizyo)
    # print(keta)
    for i, v in enumerate(keta):
        c = v * (n-v) % MOD
        ans += c * kaizyo[i]
        ans = ans
        # print(ans, c, kaizyo[i])

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

Submission status: Wrong Answer

Solution code:

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

total = 0

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

print(total)

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

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
numbers = list(map(int,input().split(" ")))

count = 0

conv = list(itertools.permutations(numbers, r=2))


for j in conv:
    pair = (j[0]^j[1])
    count += pair
        
print(count%(10**9+7)//2)

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
a = sorted(list(set(a)))
mod = 10**9 + 7
ans = 0
l = len(a)
for i in range(l-1):
    for j in range(i,l):
        ans += ( a[i]^a[j] ) % mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
def factorial( n) : 
    M = input()
    f = 1
  
    for i in range(1, n + 1):  
        f = f * i
    return f % M

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import xor

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

res = 0
for i,Ai in enumerate(A_arr[:-1]):
    res += sum(map(lambda yj: Ai ^ yj, A_arr[i+1:]))
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())))
s = 0

for i in range(N-1):
    s += np.sum(np.bitwise_xor(A[i+1:N],A[i]))

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

Submission status: Wrong Answer

Solution code:
N = input()
a = list(map(int, input().split()))
i = 0
sum = 0
while i < len(a)-1:
  for j in range(i+1, len(a)):
    #print(i, j)
    sum += a[i]^a[j]
    if sum >= 1000000007:
      sum -= 10000000007
  i += 1
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, 128): 
  
        #  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
  
  
print(sumXOR(A, N)  % 1000000007)

Submission status: Wrong Answer

Solution code:
def factorial( n) : 
    M = 1000000007
    f = 1
  
    for i in range(1, n + 1):  
        f = f * i
    return f % M

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

Submission status: Wrong Answer

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

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]
    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:
N = int(input())
A = list(map(int,input().split()))

num = 0

def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X)+1)):
        out += int(X[-i])*(n**(i-1))
    return out


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

print(num)

Submission status: Wrong Answer

Solution code:
#ABC-D

def solve():
    import numpy as np
    n=int(input())
    a=np.array(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]
    
    print(ans%(10**9+7))

solve()

Submission status: Wrong Answer

Solution code:
import math
import queue
import bisect
import heapq
import time
import itertools

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def main():
    n = int(input())
    a = [x for x in 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 %= mod
    print(int(ans))
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

AList = []
A = list(map(int, input().split()))
for i in range(0, N):
    AList.append(bin(A[i]))
    """
    count = 0
    i = 0
    while A != 0:
        count += (A % 2) * (10 ** i)
        A = A // 2
        i += 1
    AList.append(count)
    """
    
print(AList)
count = 0
for i in range(0, N):
    for q in range(i, N):
        count += int(bin(int(AList[i], 2) ^ int(AList[q], 2)), 2)
        
print(count % (10 ** 9 + 7))

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
      
      
      
    # driver function  
sum = 0
a=0
n=int(input())
arr=list(map(int,input().split()))
sum = sumXOR(arr, n); 
print (sum)

Submission status: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7


def solve(n, a):
    m = 61
    b = [('0'*m + bin(a[i])[2:])[-1:-m:-1] for i in range(n)]
    cnt_bit = [0] * m
    for i in range(n):
        for j, c in enumerate(b[i]):
            if c == '1':
                cnt_bit[j] += 1
    total = 0
    k = 1
    for i in range(m-1):
        for j in range(n):
            if b[j][i] == '0':
                total += k * cnt_bit[i]
            if b[j][i] == '1':
                total += k * (n - cnt_bit[i])
        total %= MOD
        k = (k*2 % MOD)
    return (total//2) % MOD


def bf(n, a):
    total = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            total += (a[i] ^ a[j])
    return total % MOD


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    print(solve(n, a))
    # print(bf(n, a))

Submission status: Wrong Answer

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

n=int(input())
a=list(map(int, input().split()))
s = 0
for i in range(0,n-1):
    for j in range(i+1,n):
        res = a[i] ^ a[j]
        s += res
        print(res)
print(s% (1000000000 + 7))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
import numpy as np
c = np.array([0 for _ in range(len(bin(max(a))) - 2)])
len_c = len(c)
ans = 0
mod = 10**9 + 7
cnt = 0
for i in range(n):
  binlist = np.array(list(map(int, list('0' * (len_c - len(bin(a[i])) + 2) + bin(a[i])[2:]))))
  for j in range(len_c):
    power = 2**(len_c-j-1)
    if binlist[j] == 0:
      ans += c[j] * power
    else:
      ans += (cnt - c[j]) * power
  ans %= mod
  c += binlist
  cnt += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
L = np.array([int(i) for i in input().split()], dtype="uint64")
out = 0
modu = pow(10,9)+7

for i in range(n-1):
  T = (L ^ np.roll(L,i+1) ) % modu
  out += int((np.sum(T) % modu))
  out = out % modu
print(out//2)

Submission status: Wrong Answer

Solution code:
N = input()
inputs = input()
inputs = [int(num) for num in inputs.split(' ')]
nums = inputs[1:]
sum = 0
for i in nums:
    for j in nums:
        if i < j:
            sum += i^j
print(sum)

Submission status: Wrong Answer

Solution code:
def add(a,b):
  mod=1000000007
  return (a+b)%mod
 
a=int(input())
b=list(map(int,input().split()))
s=0
count=0
for i in range(len(b)-1):
  for j in range(i+1,len(b)):
    if count!=10000:
      s=s+b[i]^b[j]
      count+=1
    else:
      s=add(s,b[i]^b[j])
      count=0
s=add(0,s)
print(s)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
import datetime
import itertools

# 入力
N = int(input())
S = str(input())
#N, A, B = map(int, input().split())
#A, B, C = map(int, input().split())

Z = (10 ** 9) + 7
list = list(map(int, list(set(S.split()))))

sum = 0
for v in itertools.combinations(list, 2):
    #print(v)
    sum += v[0] ^ v[1]
print (sum%Z)

Submission status: Wrong Answer

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

total = 0

for i in range(n-1):
  for j in range(n-(i+1)):
    total += (a[i] ^ a[(i+1)+j]) % ((10**9) + 7)

print(total)

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

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 
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
				
			else: 
				oc = oc + 1
			arr[j] = int(arr[j] / 2) 
		
		
		# calculating individual bit sum 
		curr=(oc*zc)%mod
		idsum = (curr * ((1 << i)%mod))%mod
		# final sum	 
		sum = (sum + (idsum)%mod )%mod
	
	return sum%mod



# driver function 
sum = 0
n=int(input())
arr = list(map(int,input().split())) 
for i in range(n):
    arr[i]=arr[i]
sum = sumXOR(arr, n); 
print (sum) 

# This code is contributed by saloni1297

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(lambda x: int(x), input().split()))
res = 0
MOD = 1e9 + 7
for i in range(60):
    w = 1 << i
    c1 = 0
    c0 = 0
    for j in a:
        t = w & j
        if t == 0:
            c0 += 1
        else:
            c1 += 1
    res = (res + w * c0 % MOD * c1 % MOD) % MOD
print (res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
import numpy as np
c = np.array([0 for _ in range(len(bin(max(a))) - 2)])
len_c = len(c)
ans = 0
mod = 10**9 + 7
cnt = 0
for i in range(n):
  binlist = np.array(list(map(int, list('0' * (len_c - len(bin(a[i])) + 2) + bin(a[i])[2:]))))
  for j in range(len_c):
    if binlist[j] == 0:
      ans = (ans + c[j] * (2**(len_c-j-1))) % mod
    else:
      ans = (ans + (cnt - c[j]) * (2**(len_c-j-1))) % mod
  c += binlist
  cnt += 1
print(ans)

Submission status: Wrong Answer

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

# ans = 0
# for v in combinations(A, 2):
#     ans += v[0] ^ v[1]
ans =sum([v[0]^v[1] for  v in combinations(A, 2)])
print(int(ans % (10e8+7)))

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
lis = list(map(int, input().split()))

sum =0
for i in itertools.permutations(lis, r=2):
    sum = sum + (i[0] ^ i[1])

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

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
    p = [[0, 0] for i in range(k)]
    for sa in a:
        for j in range(k):
            if 2 ** j & sa != 0:
                p[j][1] += 1
            else:
                p[j][0] += 1
    res = 0
    for sa in a:
        for j in range(k):
            if 2 ** j & sa != 0:
                res += 2 ** j * p[j][0]
                res %= mod
            else:
                res += 2 ** j * p[j][1]
                res %= mod
    print(res // 2)


main()

Submission status: Wrong Answer

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

res = 0

for i in range(len(a)):
  for j in range(i, len(a)):
    res += a[i] ^ a[j]
print(res % 1000000007)