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

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())
a = list(map(int, input().split()))
ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:

def hoge(n):
    return int(n)%(10**9+7)

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

AA = list(map(hoge, A))

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

Submission status: Wrong Answer

Solution code:
import itertools

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

xor = 0
patern = list(itertools.combinations(a, 2))
for p in patern:
    xor += p[0] ^ p[1]
if xor >= 10 ** 9:
    s = xor - 10 **9
    print(s % 7)
else:
    print(xor)

Submission status: Wrong Answer

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

res = 0

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

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):
  T = (L ^ np.roll(L,i) ) % modu
  out += int((np.sum(T) % modu))
print((out % modu)//2)

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
a = 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 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))])
    print(result%(10^9+7))    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
MOD = 10**9+7
s = 0
n = int(input())
a = list(map(int,input().split()))
for i in range(n-1):
    s += sum(np.bitwise_xor(a[i+1:],a[i]))
print(s%MOD)

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!=10:
      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:
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 xorsum(arr, n, modu = int(10e9 + 7)): 
    ans = 0
    for i in range(60): # elements in arr less than 2^60
        zc = oc = ind_sum = 0
        for j in range(n): 
            if (arr[j] % 2):
                oc += 1
            else:
                zc += 1
            arr[j] = int(arr[j] / 2) 
        ind_sum = oc * zc * (1 << i)
        ans += ind_sum
    return ans % modu

if __name__ == "__main__":
    import sys
    in_arr = []
    for line in sys.stdin:
        in_arr.append([int(_) for _ in line.strip().split()])
    arr = in_arr[1]
    print(xorsum(arr, len(arr)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = list(map(int, input().split()))
sum = 0

for i in range(N-1):
    for j in range(i+1, N):
        print("i= " + str(A_list[i]) + " j= " + str(A_list[j]))
        print(A_list[i] ^ A_list[j])
        sum += A_list[i] ^ A_list[j]

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def XOR( arr, n): 
	sumi = 0
	for i in range(0, 60): 
		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	 
		sumi = (sumi%mod + idsum%mod)%mod; 
	return sumi%mod
mod = 10**9+7
n = int(input())
ls = list(map(int,input().strip().split()))
print(XOR(ls, n))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+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
        sum %= MOD
    return sum
 
sum = sumXOR(A, N)
print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np
MOD = 10**9+7
s = 0
n = int(input())
a = list(map(int,input().split()))
for i in range(n-1):
    s += sum(np.bitwise_xor(a[i+1:],a[i]))%MOD
print(s)

Submission status: Wrong Answer

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

num = 1000000007

sum = 0
for i in range(N+1):
    for j in range(i+1, N):
        sum += (data[i] ^ data[j]) % 10

print(sum%8)

Submission status: Wrong Answer

Solution code:
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 % (1000000007))

Submission status: Wrong Answer

Solution code:
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
    
n = int(input())
a = list(map(int,input().split()))

print(sumXOR(a,n)%(10**9+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
mod = 10**9 + 7
A = [int(i) for i in input().split()]
bits = [0]*61

ans = 0
for i, a in enumerate(A):
    for b in range(len(bin(a))-2):
        if (a >> b) & 1:
            ans += (2**b)*(i-bits[b])
            bits[b] += 1
        else:
            ans += (2**b)*bits[b]
    ans %= mod
print(ans)

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))])
    print(result)    

if __name__ == "__main__":
    main()

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())
a = list(map(int,input().split()))

print(sumXOR(a,n)%(10**9+7))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
ma = max(a)
maketa = len(bin(ma))-2
print(maketa)
res = 0
for i in range(1,maketa+1):
    num = 0
    for j in range(N):
        num += a[j] % 2
        a[j] = a[j] // 2
    res += num*(N-num)*(2**(i-1))
print(res%(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
mod = 1000000007
ans = 0
N = int(input())
nums = list(map(int, input().split()))
ans = sumXOR(nums, N);
print ( ans % mod)

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;  
        sum%=10**9+7
    return sum
  
  
  
  
sum = 0
n=int(input())
arr=list(map(int,input().split()))
sum = sumXOR(arr, n); 
sum%=10**9+7
print (sum)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

mod = 10**7 + 7
ans = 0
for i in range(60):
    bit = 2**i
    one_count = 0
    for x in a:
        one_count += 1 if x & bit != 0 else 0
    ans += (n-one_count) * one_count * bit % mod

print(ans)

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())
a = list(map(int,input().split()))

print(sumXOR(a,n)%(10**9+7))

Submission status: Wrong Answer

Solution code:
_ = input()
A = list(map(int, input().strip().split()))
n = len(A)
res = 0
for i in range(n-1):
    for j in range(i+1, n):
        res += (A[i]^A[j])
        print(A[i], A[j], res)
res = res % (int(1e9) + 7)
print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
N = 60

a = map(int, input().split())
nums = []
for aa in a:
    b = list(reversed(list(map(int, format(aa, "060b")))))
    nums.append(b)
nums = np.array(nums)
res = 0
MOD = int(1e9+7)
k = np.full(N, n*(n-1)/2)
n1 = nums.sum(0)
n0 = n-nums.sum(0)
k -= n1*(n1-1)//2
k -= n0*(n0-1)//2
k *= (2**np.arange(N)) % MOD

res = 0
for kk in k:
    res += kk
    res %= MOD


print(int(res))

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

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

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 
mod=1000000007
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 
		curr=(oc*zc)%mod
		idsum = (curr * ((1 << i)%mod))%mod
		# final sum	 
		sum = (sum + idsum )%mod
	
	return sum



# 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:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
MOD = 10**9 + 7

def sumXOR(arr, n): 
    sumation = 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) 
        sumation = sumation + idsum
        sumation %= MOD
      
    return sumation
  
n = int(input())
a = [int(item) for item in input().split()]
  
print(sumXOR(a, n))

Submission status: Wrong Answer

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

from itertools import combinations

ans = 0
for v in combinations(A, 2):
    ans += v[0] ^ v[1]

print(int(ans% (10e8+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
    
n = int(input())
a = list(map(int,input().split()))

print(sumXOR(a,n)%1000000007)

Submission status: Wrong Answer

Solution code:
import itertools

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

c = itertools.combinations(nums, 2)
loopnum=len(list(c))
c = itertools.combinations(nums, 2)
sum = 0
for i in range(loopnum):
  temp = next(c)
  sum += temp[0]^temp[1]
print(sum)

Submission status: Wrong Answer

Solution code:
def xorsum(arr, n, modu = int(10e8 + 7)): 
    ans = 0
    for i in range(60): # elements in arr less than 2^60
        zc = oc = ind_sum = 0
        for j in range(n): 
            if (arr[j] % 2):
                oc += 1
            else:
                zc += 1
            arr[j] = int(arr[j] / 2) 
        ind_sum = oc * zc * (1 << i)
        ans += ind_sum
        ans %= modu
    return ans

if __name__ == "__main__":
    import sys
    in_arr = []
    for line in sys.stdin:
        in_arr.append([int(_) for _ in line.strip().split()])
    arr = in_arr[1]
    print(xorsum(arr, len(arr)))

Submission status: Wrong Answer

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

from itertools import combinations

ans = 0
for v in combinations(A, 2):
    ans += v[0] ^ v[1]
    print(v, ans)

print(int(ans% (10e8+7)))

Submission status: Wrong Answer

Solution code:
import itertools

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

INF = 10**9 + 7


B = list(itertools.combinations(A,2))
ans = 0
for i in B:
    ans += (i[0] ^ i[1])

print(ans)

Submission status: Wrong Answer

Solution code:

import numpy as np

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

while(len(a) > 1):
    a = np.delete(a, -1)
    b = np.delete(b, 0)
    sum += np.sum(a^b)

print(int(sum % (1E9 + 7)))

Submission status: Wrong Answer

Solution code:
def sums( 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
  

s = 10**9+7
sum = 0
n = int(input())
v = list(map(int,input().split()))
sum = sums(v, n)
sum%=s
print (sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
cnt=[0 for i in range(64)]
mask=1
for i in range(64):
    for j in a:
        if j|mask==j: #立っている
            cnt[i]+=1
    mask*=2
x=1
res=0
for i in range(64):
    res+=2*cnt[i]*(n-cnt[i])*x
    res%=1000000007
    x*=2
print(res//2)

Submission status: Wrong Answer

Solution code:
import itertools

input()

def to_bin(s):
  return bin(int(s))[2:]
  
a_list = list(map(to_bin, input().split(" ")))
s_list = []

for a in itertools.combinations(a_list, 2):
  n = len(a[0]) if len(a[0]) > len(a[1]) else len(a[1])
  a0 = a[0].zfill(n)
  a1 = a[1].zfill(n)
  s = ""
  for a_0, a_1 in zip(a0, a1):
    if a_0 == "1" and a_1 == "0":
      s += "1"
    elif a_0 == "0" and a_1 == "1":
      s += "1"
    else:
      s += "0"
  s_list.append(int(s, 2))
print(sum(s_list))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
MOD = 10**9 + 7

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) 
   
        # final sum     
        sum = sum + idsum;  
      
    return sum % MOD
  
n = int(input())
a = [int(item) for item in input().split()]
  
print(sumXOR(a, n))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
li=list(map(int, input().split()))
cnt=0

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

print(cnt)

Submission status: Wrong Answer

Solution code:
def xorSum(arr, n): 
  
    bits = 0
  
    for i in range(n): 
        bits |= arr[i] 
  
    ans = bits * pow(2, n-1) 
  
    return ans 
  
s = input()
arr = list(map(int, s.split()))
size = len(arr) 
print(xorSum(arr, size))

Submission status: Wrong Answer

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

def from10to2(x):
  y = []
  while x>0:
    a = x//2
    b = x%2
    y.append(b)
    x = a
  return y[::-1]

def from2to10(y):
  y = y[::-1]
  n = len(y)
  x = 0
  for i in range(n):
    x += y[i] * 2**i
  return x

def xor(A,B):
  A2 = from10to2(A)
  B2 = from10to2(B)
  C = []
  num = max(len(A2),len(B2))
  
  if len(A2)<num:
    A2_ = [0 for i in range(num-len(A2))]
    A2 = A2_ + A2
  elif len(B2)<num:
    B2_ = [0 for i in range(num-len(B2))]
    B2 = B2_ + B2
  
  for i in range(num):
    if A2[i]+B2[i]==1:
      C.append(1)
    else:
      C.append(0)
  return from2to10(C)
    

sum = 0
for i in range(N-1):
  for j in range(i+1,N):
    sum += xor(As[i],As[j])
    
ans = sum % (7 + 1e+9)
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
N = 60

a = map(int, input().split())
nums = []
for aa in a:
    b = list(reversed(list(map(int, format(aa, "060b")))))
    nums.append(b)
nums = np.array(nums)
res = 0
MOD = int(1e9+7)

for i, col in enumerate(nums.T):
    k = n*(n-1)/2
    n1 = col.sum()
    n0 = n-col.sum()
    k -= n1*(n1-1)/2
    k -= n0*(n0-1)/2
    res += (1 << i) * k
    res %= MOD

print(int(res))

Submission status: Wrong Answer

Solution code:
import itertools

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

total = 0

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

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
MOD = 10**9 + 7


def sumXOR(arr, n):
    sm = 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
        sm += idsum

    return sm % MOD


# driver function
sm = 0
n = int(input())
arr = list(map(int, input().split()))
sm = sumXOR(arr, n)
print(sm)

# This code is contributed by saloni1297

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class Solver(object):
    def __init__(self):
        pass

    def solve(self, n, arr):
        sum = 0
        for i in range(128):
            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 % (10**9 + 7)


def main():
    N = int(input())
    A_l = [int(i) for i in input().split()]
    solver = Solver()
    print(solver.solve(N, A_l))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    zeros = [0 for _ in range(61)]
    ones = [0 for _ in range(61)]
    for a in A:
        for i in range(61):
            if (a >> i) & 1:
                ones[i] += 1
            else:
                zeros[i] += 1

    res = 0
    for a in A:
        for i in range(61):
            if (a >> i) & 1:
                res += zeros[i] << i
                res %= MOD
            else:
                res += ones[i] << i
                res %= MOD
    print(res // 2)
        
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class Solver(object):
    def __init__(self):
        pass

    def solve(self, n, arr):
        sum = 0
        for i in range(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 % (10**9 + 7)


def main():
    N = int(input())
    A_l = [int(i) for i in input().split()]
    solver = Solver()
    print(solver.solve(N, A_l))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
MOD = 10**9 + 7


def sumXOR(arr, n):
    sm = 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
        sm += idsum
        sm %= MOD

    return sm % MOD


# driver function
sm = 0
n = int(input())
arr = list(map(int, input().split()))
sm = sumXOR(arr, n)
print(sm)

# This code is contributed by saloni1297

Submission status: Wrong Answer

Solution code:
def pairORSum(arr, n) : 
    ans = 0  
    for i in range(0, n) : 
          
        for j in range(i + 1, n) : 
              
            ans = ans + (arr[i] ^ arr[j]) 
              
    return ans 

arr = [ 5, 9, 7, 6 ] 
n = len(arr) 
  
print(pairORSum(arr, n))

Submission status: Wrong Answer

Solution code:
MOD = 10**9 + 7


def sumXOR(arr, n):
    sm = 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
        sm += idsum
        sm %= MOD

    return sm % MOD


# driver function
sm = 0
n = int(input())
arr = list(map(int, input().split()))
sm = sumXOR(arr, n)
print(sm)

# This code is contributed by saloni1297

Submission status: Wrong Answer

Solution code:
#!python3.4.3

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

Submission status: Wrong Answer

Solution code:
n = 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 = input().split()

tmp = 0
for i in range(len(A)-1):
    tmp += int(A[i]) ^ int(A[i+1])
print(tmp % (10**9)+7)

Submission status: Wrong Answer

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

bit = [0] * 50

for a in al:
    for i in range(50):
        bit[i] += (a % 2)
        bit[i] %= 10**9 + 7
        a = a // 2

ans = 0
p = 1
for i in range(50):
    ans += bit[i] * (n - bit[i]) * p
    ans %= 10**9 + 7
    p *= 2

print(ans)

Submission status: Wrong Answer

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

tmp = 0
for i in range(len(A)-1):
    tmp += int(A[i]) ^ int(A[i+1])
print(tmp / (10**9)+7)

Submission status: Wrong Answer

Solution code:
def XOR( arr, n): 
	sum = 0
	for i in range(0, 64): 
		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%mod + idsum%mod)%mod; 
	return sum%mod
mod = 10**9+7
n = int(input())
ls = list(map(int,input().strip().split()))
print(XOR(ls, n))

Submission status: Wrong Answer

Solution code:
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))

n, = I()
a = I()
ans = 0
for bit in range(64):
    c = [0, 0]
    for i in a:
        c[(i >> bit)&1] += 1
    ans += c[0] * c[1] * 2**bit
    # print(ans, c[0], c[1], 2**i)
print(ans)

Submission status: Wrong Answer

Solution code:
def solve(a,n):
	s = 0
	mod = 1000*1000*1000 + 7
	for i in range(0,32):
		zc,oc = 0,0
		for j in range(n):
			if a[j]%2!=0:
				oc+=1
			else:
				zc+=1
			a[j] = a[j]//2
		l = oc%mod * zc%mod * (1<<i)%mod
		s = s + l
		s %= mod
	return s

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

ans = solve(a,n)
print(ans)