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:
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, 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) % MOD
        idsum = idsum * (1 << i)

        # final sum
        idsum %= MOD
        _sum = _sum + idsum
        _sum %= MOD

    return _sum


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def d(A, d):
    return (A >> d) & 1

def main():
    N = int(input())
    A = [int(i) for i in input().split()]

    _s = 0
    S = [[0]*60 for _ in range(N)]
    S[0] = [d(A[0],j) for j in range(60)]
    for i in range(1,N):
        for j in range(60):
            S[i][j] += S[i-1][j] + d(A[i], j)
    res = 0
    for i in range(1,N):
        for j in range(60):
            if d(A[i],j) == 0:
                res += (S[i-1][j])*(2**j)
            else:
                res += (i - S[i-1][j])*(2**j)
    print(res)
    print(S)
    # dp = [[0]*N for _ in range(60)]
    # dp[0] = [d(S[i], 0) for i in range(N)]
    # for i in range(1,60):
    #     for j in range(N):
    #         dp[i][j] = dp[i][j-1] ^ d(S[j-1] ^ (A[j] if (N-1)%2==0 else 0), i) ^ (1 if dp[i-1][j-1] > dp[i-1][j] else 0)
    # res = 0
    # for a in reversed(dp[N-1]):
    #     res <<= 1
    #     res += a
    # print(res)
main()

Submission status: Wrong Answer

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

ans = 0
for i in range(61):
  c0 = 0
  c1 = 0
  for a in A:
    if (a>>i)&1 == 1:
      c1 += 1
    else:
      c0 += 1
  #print(c1,c0)
  ans += ((c0*c1)<<i)
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n  = int(input())
m  = 10 ** 9 + 7
l  = 2 ** 32
xs = [int(x) for x in input().split()]
r  = 0

for i in range(0, n - 1):
	for j in range(i + 1, n):
		r = (r + ((xs[i] ^ xs[j]) % l)) % m

print(r)

Submission status: Wrong Answer

Solution code:
import numpy
n=int(input())
l=map(int,input().split())
dic=dict(zip(range(n),l))
ans=0
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        ans+=numpy.bitwise_xor(dic[i],dic[j])
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
MOD = 1000000007
nums = list(map(int, input().split(' ')))
MASK = 2**34-1
nums = map(lambda x: x & MASK, nums)

ret = 0
combi = itertools.combinations(nums, 2)
for x, y in combi:
  ret = (ret + (x ^ y))% MOD
print(ret)

Submission status: Wrong Answer

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

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

        # print("\t"+str(nj))
        # print(bin(ni ^ nj))
        ans += int(bin(ni ^ nj)[2:], 2)
print(ans)

Submission status: Wrong Answer

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

s = [0] * 61
for i in range(n):
    for j in range(61):
        if ((1 << j) & a[i]) > 0:
            s[j] += 1

mod = 10**9 + 7

ans = 0
for i in range(n):
    for j in range(61):
        if ((1 << j) & a[i]) == 0:
            ans += pow(2, j, mod) * s[j] % mod
        else:
            ans += pow(2, j, mod) * (n-s[j]) % mod
        ans %= mod

print(ans)

Submission status: Wrong Answer

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

def da_generate(h,w,b):
    da = [[0]*w for j in range(h)]
    da[0][0] = 0
    for i in range(1,w):
        da[0][i] = da[0][i-1]+b[0]^b[i]
    for i in range(1,h):
        cnt_w = 0
        for j in range(w):
            cnt_w += b[i]^b[j]
            da[i][j] = da[i-1][j]+cnt_w
    return da

da = da_generate(n,n,b)

#da_calc(p,q,x,y):(p,q)~(x,y)の長方形の和
def da_calc(p,q,x,y):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y]-da[x][q-1]
    if q == 0:
        return da[x][y]-da[p-1][y]
    return da[x][y]-da[p-1][y]-da[x][q-1]+da[p-1][q-1]

print(da_calc(0,0,n-1, n-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def print_ans(N, ar):
    """Test Case
    >>> print_ans(3, [1, 2, 3])
    6
    >>> print_ans(10, [3, 1, 4, 1, 5, 9, 2, 6, 5, 3])
    237
    >>> print_ans(10, [3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820])
    103715602
    """
    ans_list = [0] * N
    for i in range(len(ar) - 1):
        tmp = ar[i]
        for a in ar[i+1:]:
            tmp ^= a
        ans_list[i] = tmp
    print(sum(ans_list) % (10 ** 9 + 7))
    # ans = 0
    # for i in range(N -1):
    #     for k in range(i, N):
    #         ans += ar[i] ^ ar[k]
    # print(ans % (10 ** 9 + 7))

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = list(map(int, input().rstrip().split()))
    print_ans(N, ar)

Submission status: Wrong Answer

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

a.append(-1)

result=0
for i in range(len(a)-1):
  for j in range(i+1,ori_num,2):
    if -1==j+1:
      result+=a[i]^a[j]
    else:
      result+=a[j]+a[j+1]
    
print(result%(10**9+7))

Submission status: Wrong Answer

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

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) % MOD
        idsum = idsum * (1 << i)

        # final sum
        idsum %= MOD
        _sum = _sum + idsum
        _sum %= MOD

    return _sum


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


if __name__ == '__main__':
    main()

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] = arr[j]  >> 1;
        # calculating individual bit sum
        idsum = oc * zc * (1 << i)
        # final sum
        s = (s + idsum)%(1e9+7);
    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:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(N):
    ans += (A[i] ^ sum(A))
print(ans%mod)

Submission status: Wrong Answer

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r)%(10**9-7) + cmb(n-1,r-1) % (10**9-7)
    return nCr[(n,r)]


for i in a:
    b.append(format(i,'0' + str(len(format(max(a),'b')))+'b'))
#print(b)
l = len(b[0])
dic = {}
for j in range(l):
    dic[2 ** (j)] = 0
#print(dic)
for i in range(n):
    for j in range(l):
        if b[i][j] == '1':
            dic[2 ** (l-j-1)] += 1 #1の回数
ans  = 0
for i in dic.keys():
#    print(i)
    if dic[i] < 2:
        only1 = 0
    else:
        only1 = cmb(dic[i],2)
    if n - dic[i] < 2:
        only0 = 0
    else:
        only0 = cmb(n - dic[i],2)
    #print(only0,only1)
    ans += i * (cmb(n,2) - only0 - only1)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from operator import xor
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

answer = 0
for i in range(N-1):
    a = A[i+1:]
    answer += sum(xor(a,A[i]))

print(answer % MOD)

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:
MOD = 1000000007

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

def sumXOR(arr,n):

    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 += idsum
        sum %= MOD

    return sum

sum = 0
sum = sumXOR(A,N);
print(sum%MOD)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
lst = [0 for _ in range(70)]

# fac[i] = i!
# inv[i] = iの逆元

fac = [1]
inv = [1]

for i in range(1, N + 10) :
	fac.append(fac[-1] * i % MOD)
	inv.append(pow(fac[-1], MOD - 2, MOD))

for a in A:
	cur = bin(a)
	ctr = 0
	for i in reversed(range(len(cur))):
		if cur[i] == "b": break
		else:
			lst[ctr] += int(cur[i])
		ctr += 1
			
ans = 0

for i in range(len(lst)):
	ans += lst[i] * (2 ** i) * (N - 1) % MOD

for i in range(len(lst)):
	if lst[i] == 0: continue
	ans -= (2 ** i) * (fac[lst[i]] * inv[lst[i] - 2] * inv[2]) * 2 % MOD
	ans %= MOD
	
print(ans)

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 != []:
  m = 0
  n = len(A)
  k = []
  for i in range(n):
    if A[i] % 2 == 1:
      m += 1
    A[i] //= 2
    if A[i] == 0:
      k.append(i)
  for g in range(len(k)):
    A.remove(A[k[len(k)-1-g]])
  S += (m * (N - m)) * (2 ** j)
  S %= mod
  j += 1
print(S)

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

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, 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) % MOD
        idsum = idsum * (1 << i)

        # final sum
        idsum %= MOD
        _sum = _sum + idsum
        _sum %= MOD

    return _sum


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
x = int(input())
a = list(map(int, input().strip().split()))
s = 1e9+7
list1=[]
for i in range(0, x-1 ):
    for j in range(i + 1, x):
        list1.append(a[i]^a[j])
Sum = 0
for i in list1:
    Sum += i
x1 = int(Sum%s)
print(x1)

Submission status: Wrong Answer

Solution code:

n = int(input())
ls = list(map(int,input().split()))
mod = 10**9 + 7
check = [[0]*61 for i in range(n+1)]
bit = [[False]*61 for i in range(n+1)]
index = n-1
for i in range(n,0,-1):
    c = ls[i - 1]
    co = 60
    wari = 2 ** 60
    check[i - 1] = [o for o in check[i]]
    while c > 0:
        check[i - 1][co] = check[i][co]
        if c < wari:
            co -= 1
            wari //= 2
            continue
        check[i - 1][co] += (c >= wari) + 0
        bit[i-1][co] = (c >= wari)
        co -= 1
        c %= wari
        wari //= 2

ans = 0
c = 0
for j in range(n - 1):
    c = 0
    for i in range(60):

        ans += (2 ** c) * check[j + 1][c] * ((not bit[j][c]) + 0) + (2 ** c) * (j + 1 - 1 - check[j + 1][c]) * ((bit[j][c]) + 0)
        c += 1
        ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

n = input()
l = list(map(int,input().split()))
c = itertools.combinations(l,2)

s = 0

for v in c:
    s += ((v[0]%1073741823)^(v[1]%1073741823))% (10**9+7)
    if(s >= 10**9+7):
        s = s % (10**9+7)

print(s)

Submission status: Wrong Answer

Solution code:
import numpy as np
from operator import xor
import sys
sys.setrecursionlimit
input = sys.stdin.readline

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

answer = 0
for i in range(N-1):
    a = A[i+1:]
    answer += sum(xor(a,A[i]))

print(answer % MOD)

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7
N = int(input())
Data = list(map(int,input().split()))
sum0 = sum(Data)
sum1 = sum(Data)*N*2 
sum2 = 0
for v in Data:
    sum2 += (v & sum0)
ans = ((sum1 - 2*N*sum2) // 2) % MOD
print(ans)

Submission status: Wrong Answer

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

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

L = len(Base_10_to_n(A[-1],2))

cnt = [0] * L
ans = 0
for i in range(1,N):
	tmp = A[0]^A[i]
	ans += tmp
	tt = Base_10_to_n(tmp,2).rjust(L,"0")
	for j in range(L):
		if tt[j] == "1":
			cnt[j] += 1
T= ans
ans %= mod

for i in range(1,N):
	TT = T
	tmp=0
	t = A[0]^A[i]
	tt = Base_10_to_n(t,2).rjust(L,"0")
	ttt = list(map(int, tt))
	for j in range(L):
		if ttt[j] == 1:
			tmp -= 2**(L-1-j) * cnt[j]
			tmp += 2**(L-1-j) * (N-cnt[j])
	TT += tmp
	ans += TT
	ans %= mod

ans //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
mod=1000000007
ans=0
n=int(input())
a=[int(i) for i in input().split()]
x=[[0]*63 for i in range(n)]
for i in range(n):
    d=bin(a[i])[2:]
    for j,k in enumerate(d[::-1]):
        x[i][j]=x[i-1][j]+[0,1][k=='1']
#print(x)
for i in range(n-1):
    #print(a[i])
    d=bin(a[i])[2:]+'0'*65
    #print(d)
    for j in range(63):
        r=x[-1][j]-x[i][j]
        if d[j]=='1':
            ans+=(2**j)*r
        else:
            ans+=(2**j)*(n-i-r)
        #r=(n-i)-(x[-1][j]-x[i][j])
        #ans+=(2**j)*r
        ans%=mod
print(ans)

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):
    ans += (A[i] ^ sum(A))
    ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
a = int(input())
d=list(map(int,input().split()))
b=np.array(d)
c=10**9+7
l=[]
for i in range(0,a-1):
    for j in range(i+1,a):
        l.append(np.bitwise_xor(b[i], b[j]))
print(sum(l)%c)

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):
        ans += A[i]^A[j]
        
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
A=list(map(int,input().split()))
S=0
mod=10**9+7
for v in itertools.combinations(A,2):
    S+=(v[0]^v[1])%mod
print(S)

Submission status: Wrong Answer

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

for i in range(l-1):
    for j in range(i+1,l):
        k = A[i]^A[j]
        c = c+k

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

Submission status: Wrong Answer

Solution code:
mod=1000000007
ans=0
n=int(input())
a=[int(i) for i in input().split()]
x=[[0]*63 for i in range(n)]
for i in range(n):
    d=bin(a[i])[2:]
    for j,k in enumerate(d[::-1]):
        x[i][j]=x[i-1][j]+[0,1][k=='1']
#print(x)
for i in range(n-1):
    #print(a[i])
    d=bin(a[i])[2:]+'0'*65
    #print(d)
    for j in range(63):
        r=x[-1][j]-x[i][j]
        if d[j]=='0':
            ans+=(2**j)*r
        else:
            ans+=(2**j)*(n-i-r)
        #r=(n-i)-(x[-1][j]-x[i][j])
        #ans+=(2**j)*r
        ans%=mod
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = []
n = 0
for x in xs:
    y = list(reversed(bin(x)))[:-2]
    ys.append(y)
    n = max(n, len(y))
print(ys, n)
ans = 0
for i in range(n):
    x0 = 0
    x1 = 0
    for y in ys:
        #print(y,i,len(y))
        if i < len(y):
            if y[i] == "1":
                x1 += 1
            else:
                x0 +=1
        else:
            x0 += 1
    #print(x1,x0)
    ans += x1 * x0 * (2**(i))
    ans %= 10**9 + 7
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())
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=list(map(int,input().split()))
c=0
for i in range(n-1):
  for j in range(i+1,n):
    c+=a[i] ^ a[j]
print(c)

Submission status: Wrong Answer

Solution code:
import numpy as np
from operator import xor

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

answer = 0
for i in range(N-1):
    a = A[i+1:]
    answer += sum(xor(a,A[i])) % MOD

print(answer % MOD)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
def main():
  N = int(input())
  A_ = list(map(int, input().split()))
  A = np.array(A_)
  ans = 0
  for i in range(N):
    for j in range(i+1,N):
      ans += A[i] ^ A[j]
  print(ans % 1000000007)

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 s:
  b=s.index(i)+1
  l=[i^k for k in s[b:]]
  goukei+=sum(l)
kotae=goukei%mod
print(kotae)

Submission status: Wrong Answer

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

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):
    for j in range(N):
        ans += A[i] ^ A[j]
        ans %= MOD

print (ans // 2 % MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
A = np.array(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])

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
MOD = 1000000007
def main():
    bits = input()
    ans = 1
    pow3 = 1
    for i, b in enumerate(reversed(bits)):
        if b == '1':
            ans = ((ans * 2 % MOD) + pow3) % MOD
        pow3 = (pow3 * 3) % MOD
    print(ans)
main()

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, 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
        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:
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, 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
        idsum %= MOD
        _sum = _sum + idsum
        _sum %= MOD

    return _sum


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import copy
num = int(input())
line = input().split()
count = 0
for i in range(0,num-1):
    for j in range(i+1,num):
        x = int(line[i])
        y = int(line[j])
        z = x^y
        count += z
p = copy.copy(count)
for i in range(9):
    p = p/10

if int(p)>=1:
    t = count-int(p)*(10^9+7)
    if t>=0:
        count = t
    else:
        count = count - (int(p)-1)*(10^9+7)


print(count)

Submission status: Wrong Answer

Solution code:
MOD = 1000000007

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

def sumXOR(arr,n):

    sum = 0
    for i in range(0,61):

        zc = 0
        oc = 0

        idsum = 0
        for j in range(0,n):
            if (arr[j] % 2 == 0):
                zc = zc + 1

            else:
                oc = oc + 1
            arr[j] = int(arr[j] / 2)

        idsum = oc * zc * (1 << i)

        sum += idsum
        sum %= MOD

    return sum

sum = 0
sum = sumXOR(A,N);
print(sum%MOD)

Submission status: Wrong Answer

Solution code:
mod=10**9 + 7

N=int(input())
A=list(map(int,input().split()))
A=[bin(i)[2:] for i in A]
nowdata=[0 for i in range(60)]
data=[0 for i in range(60)]



for i in range(N-1):
    S=A[i]
    for a in range(len(S)):
        nowdata[a]+=int(S[-a-1])
    S=A[i+1]
    for a in range(len(S)):
        if not int(S[-a-1]):
            data[a]+=nowdata[a]
        else:
            data[a]+=i+1-nowdata[a]


num=0
#print(data)
for i in range(60):
    num+=data[i]* (2**i)
    num%=mod

print(num)

Submission status: Wrong Answer

Solution code:
import numpy as np
a = int(input())

d=list(map(int,input().split()))
#b = np.insert(d)
b=np.zeros(a,dtype=np.int)
for i in range(a):
    b[i]=d[i]
#d=np.insert(b,)
c=10**9+7
l=[]
# for i in range(a):
#     b[i]=b[i]%c

for i in range(0,a-1):
    for j in range(i+1,a):
        l.append(np.bitwise_xor(b[i], b[j]) )
        #l.append(b[i]^b[j])

print(sum(l)%c)

Submission status: Wrong Answer

Solution code:
x = int(input())
a = list(map(int, input().strip().split()))
s = 1e9+7
list1=[]
for i in range(0, x-1 ):
    for j in range(i + 1, x):
        list1.append(a[i]^a[j])
Sum = 0
for i in list1:
    Sum += i
    
print(int(Sum%s))

Submission status: Wrong Answer

Solution code:
#D
import numpy as np
N=int(input())
A=list(map(int,input().split()))
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],dtype=np.int64)
    ans+=np.sum(C)
print(ans%(10**9+7))

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],dtype=np.int64)
    ans+=np.sum(C)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
import numpy as np
MOD = 1000000007
N = int(input())
A = list(map(lambda x:bin(int(x)).split('b')[1].zfill(60),input().split()))
B = np.array([0]*60)
for i in range(N):
    B += np.array(list(map(int,list(A[i]))))

C = list(B)

D = 0
for i in range(60):
    D += C[i]*(N-C[i])*(2**(59-i))%MOD

print(D)

Submission status: Wrong Answer

Solution code:
MOD = 1000000007

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

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 += idsum
        sum %= MOD

    return sum

sum = 0
sum = sumXOR(A,N);
print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
A=list(map(int,input().split()))
S=0
mod=10**9+7
for v in itertools.permutations(A,2):
    S+=v[0]^v[1]
print(S%mod//2)