qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = 60
MOD = 10**9 + 7
n = int(input())
# c1 = [0 for _ in range(N)]
c0 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) == 0:
            c0[j] += 1
        # else:
        #     c1[j] += 1

ans = 0
for i in range(n-1):
    for j in range(N):
        if a[i] & (1 << j) == 0:
            c0[j] -=1
        # else:
        #     c0[j] -=1
    for j in range(N):
        if a[i] & (1 << j) == 0:
            ans += (1<<j) * c0[j]
        else:
            ans += (1<<j) * (n-i-1-c0[j])
            #ans += (1<<j) * c1[j]

print(ans % MOD)

Fixed code:
N = 60
MOD = 10**9 + 7
n = int(input())
# c1 = [0 for _ in range(N)]
c1 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] += 1
        # else:
        #     c1[j] += 1

ans = 0
for i in range(n-1):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] -=1
        # else:
        #     c0[j] -=1
    for j in range(N):
        if a[i] & (1 << j) != 0:
            ans += (1<<j) * (n-i-1-c1[j])
        else:
            ans += (1<<j) * c1[j]
            #ans += (1<<j) * c1[j]

print(ans % MOD)
Buggy code:
n = int(input())
a = list(map(int,input().split()))
mod = 10e9+7
ans = 0
for i in range(60):
    x = 1<< i
    l = len([1 for j in a if j & x])
    ans += x * l * (n-l) % mod
    ans %= mod
print(ans)

Fixed code:
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(60):
    x = 1<< i
    l = len([1 for j in a if j & x])
    ans += x * l * (n-l) % mod
    ans %= mod
print(ans)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7

ans = 0
for i in range(60):
    X = sum([1 for x in A if (x >> 1) & 1])
    ans += (1 << i) * X * (N - X)
    ans %= mod

print(ans)


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

mod = 10**9 + 7

ans = 0
for i in range(60):
    X = sum([1 for x in A if (x >> i) & 1])
    ans += (1 << i) * X * (N - X)
    ans %= mod

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

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

ans = 0
mod = 10 ** 9 + 7

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

print(ans)


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

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

ans = 0
mod = 10 ** 9 + 7

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

print(ans)
Buggy code:
N = int(input())

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

ones = [0] * 60
m = 10 ** 9 + 7

for Ai in A:
    for digit in len(bin(Ai) - 2):
        ones[digit] += ((Ai >> digit) & 1)

res = 0
for i, num in enumerate(ones):
    res = (res + (1 << i) * num * (N - num)) % m

print(res)


Fixed code:
N = int(input())

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

ones = [0] * 60
m = 10 ** 9 + 7

for Ai in A:
    for digit in range(len(bin(Ai)) - 2):
        ones[digit] += ((Ai >> digit) & 1)

res = 0
for i, num in enumerate(ones):
    res += (1 << i) * num * (N - num)

print(res % m)
Buggy code:
import numpy as np

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

mod = 10**9 + 7
ans = 0

for i in range(60):
    c = len(A[A&1==1])
    ans = (ans + c*(N-c)*pow(2,i,mod))%mod
    a = a >> 1

print(ans)


Fixed code:
import numpy as np

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

mod = 10**9 + 7
ans = 0

for i in range(60):
    c = len(A[A&1==1])
    A >>= 1
    ans = (ans + c*(N-c)*pow(2,i,mod))%mod

print(ans)
Buggy code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split()))).reshape(n, 1)
mod = 10**9 + 7
bit = np.arange(64).reshape(1, 64)
b = np.sum((a >> bit) & 1, axis=1)
b *= n - b
ans = 0
for x in b:
    ans += x
    ans %= mod

print(ans)



Fixed code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split()))).reshape(n, 1)
mod = 10**9 + 7
bit = np.arange(64).reshape(1, 64)
b = np.sum((a >> bit) & 1, axis=0)
b *= n - b
b %= mod
b *= (1 << np.arange(64)) % mod
b %= mod
ans = 0
for x in b:
    ans += x
    ans %= mod

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


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

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


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

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

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

    print(ans)


if __name__=='__main__':
    main()

Fixed code:
import cmath
import sys

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


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

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

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

    print(ans)


if __name__=='__main__':
    main()
Buggy code:
MOD = 1000000007

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

ans = 0
for k in range(60):
    mask = 1<<k
    cnt1 = sum(1 for x in a if x&mask != 0)
    ans += cnt1*(n-cnt1)*(1<<k)
print(ans)

Fixed code:
MOD = 1000000007

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

ans = 0
for k in range(60):
    mask = 1<<k
    cnt1 = sum(1 for x in a if x&mask != 0)
    ans += cnt1*(n-cnt1)*(1<<k)
print(ans%MOD)
Buggy code:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61)[::-1]:
  ans+=2**(i)*(s[L-i-1])*(n-s[L-i-1])
  ans%=mod
print(ans)


Fixed code:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)
Buggy code:
N, *A = map(int, open(0).read().split())
A = np.array(A, dtype=np.int64)
mod = 10**9 + 7
 
ans = 0
for i in range(60):
    mask = 1 << i
    cnt = np.count_nonzero(A&mask)
    x = cnt * (N-cnt)
    x *= mask % mod
    ans += x
    ans %= mod
 
print(ans)

Fixed code:
import numpy as np
N, *A = map(int, open(0).read().split())
A = np.array(A, dtype=np.int64)
mod = 10**9 + 7
 
ans = 0
for i in range(60):
    mask = 1 << i
    cnt = np.count_nonzero(A&mask)
    x = cnt * (N-cnt)
    x *= mask % mod
    ans += x
    ans %= mod
 
print(ans)
Buggy code:
import sys
import numpy as np
 
n = int(input())
lst = [int(i) for i in sys.stdin.readline().split()]
arr = np.array(lst, np.int64)

mod = 10 ** 9 + 7
x_sum = 0

for i in range(60):
    c1 = sum(lst & 1)
    x_sum += (c1 * (n - c1) * 2 ** i)
    x_sum %= mod
    lst >>= 1
print(x_sum)

Fixed code:
import sys
import numpy as np
 
n = int(input())
lst = [int(i) for i in sys.stdin.readline().split()]
arr = np.array(lst, np.int64)

mod = 10 ** 9 + 7
x_sum = 0

for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    x_sum += (c1 * (n - c1) * 2 ** i)
    x_sum %= mod
    arr >>= 1
print(x_sum)
Buggy code:
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

for i in range(60):
    c = sum([1 for ai in a if (a >> i) & 1])
    ans += (1 << i) * c * (n-c)
    ans % = mod
print(ans)

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

ans = 0
for i in range(60):
    c = sum([1 for ai in a if (ai >> i) & 1])
    ans += (1 << i) * c * (n-c)
    ans %= mod
print(ans)
Buggy code:

mod = 10**9 + 7


def main():
    n = int(input())
    A = [int(a) for a in input().split()]
    ans = 0
    for k in range(60):
        a = 0
        for i in range(n):
            a += A[i] & 1
            A[i] << = 1
        da = (1 << k) % mod
        da *= (n - a)*a
        da %= mod
        ans += da
        ans %= mod
    print(ans)


main()


Fixed code:

mod = 10**9 + 7


def main():
    n = int(input())
    A = [int(a) for a in input().split()]
    ans = 0
    for k in range(60):
        a = 0
        for i in range(n):
            a += A[i] & 1
            A[i] >>= 1
        da = (1 << k) % mod
        da *= (n - a)*a
        da %= mod
        ans += da
        ans %= mod
    print(ans)


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

Fixed 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
    ans %= MOD
    # print(ans, c[0], c[1], 2**i)
print(ans)
Buggy code:
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
mod=10**9+7
ans=0
for k in range(2):
  m=np.count_nonzero((a>>k)&1)
  ans+=m*(n-m)*2**k
  ans%=mod
print(ans)

Fixed code:
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
mod=10**9+7
ans=0
for k in range(60):
  m=np.count_nonzero((a>>k)&1)
  ans+=m*(n-m)*2**k
  ans%=mod
print(ans)
Buggy code:
import numpy as np

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

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)

Fixed code:
import numpy as np

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

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)
Buggy code:
n=int(input())
l=sorted(list(map(int,input().split())))
for i,x in enumerate(l):
  l[i]=format(x,'63b')
memo=[0]*63
for i in range(61):
  for j in range(n):
    if l[j][i]=='1':
      memo[-i-1]+=1
now=1
ans=0
mod=10**9+7
for x in memo:
  ans+=(now*x*(n-x))%mod
  now*=2
print(ans%mod)


Fixed code:
n=int(input())
l=sorted(list(map(int,input().split())))
for i,x in enumerate(l):
  l[i]=format(x,'63b')
memo=[0]*63
for i in range(63):
  for j in range(n):
    if l[j][i]=='1':
      memo[-i-1]+=1
now=1
ans=0
mod=10**9+7
for x in memo:
  ans+=(now*x*(n-x))%mod
  now*=2
print(ans%mod)
Buggy code:
n = int(input())
aa = list(map(int, input().split()))
mod = 10**9+7
res = 1
pow2 = 1
ans = 0
for i in range(60):
    cnt = np.count_nonzero(np.array(aa)&2)
    ans = (ans + cnt * (n-cnt) * res)%mod
    res = (res*2)%mod
    pow2*=2
print(ans)

Fixed code:
import numpy as np
n = int(input())
aa = list(map(int, input().split()))
mod = 10**9+7
res = 1
pow2 = 1
ans = 0
for i in range(60):
    cnt = np.count_nonzero(np.array(aa)&pow2)
    ans = (ans + cnt * (n-cnt) * res)%mod
    res = (res*2)%mod
    pow2*=2
print(ans)
Buggy code:
import numpy as np

N = int(input())
A = np.fromstring(input(), np.int64, ' ')

result = 0
for bit in range(60):
    c = int((A & 1).sum())
    A >>= 1
    result = (result + c * (N - c) * (1 << bit)) % 1000000007
print(result)


Fixed code:
import numpy as np

N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

result = 0
for bit in range(60):
    c = int((A & 1).sum())
    A >>= 1
    result = (result + c * (N - c) * (1 << bit)) % 1000000007
print(result)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

m = 1000000007

result = 0
for bit in range(60):
    m = 1 << bit
    c = sum(a & m for a in A) >> bit
    result += (c * (N - c)) << bit
    result %= m
print(result)


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

result = 0
for bit in range(60):
    m = 1 << bit
    bits = sum((a & m for a in A))
    bits >>= bit
    result += (bits * (N -  bits)) << bit 
    result %= 1000000007
print(result)
Buggy code:
import numpy as np

N = int(input())
A = np.fromiter(map(int, input().split()))

result = 0
for b in range(60):
  bs = int(((A >> b) & 1).sum())
  result = (result + bs * (N - bs) * (1 << b)) % 1000000007
print(result)


Fixed code:
import numpy as np

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

result = 0
for b in range(60):
  bs = int(((A >> b) & 1).sum())
  result = (result + bs * (N - bs) * (1 << b)) % 1000000007
print(result)
Buggy code:
n=int(input())
a=[int(i) for i in input().split()]

a_bin=[]

for i in a:
    a_bin.append(format(i, '#062b')[2:])



def get_keta_num(keta,a_list):
    zero=0
    one=0
    for i in a_list:
        if i[-keta]=="0":
            zero+=1
        else:
            one+=1
    return zero*one

ans=0
for i in range(1,61):
    ans+=(2**(i-1))*get_keta_num(i,a_bin)

print(ans)

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

a_bin=[]

for i in a:
    a_bin.append(format(i, '#062b')[2:])



def get_keta_num(keta,a_list):
    zero=0
    one=0
    for i in a_list:
        if i[-keta]=="0":
            zero+=1
        else:
            one+=1
    return zero*one

ans=0
for i in range(1,61):
    ans+=(2**(i-1))*get_keta_num(i,a_bin)
    ans=ans%(10**9+7)

print(ans)
Buggy code:
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = 0
for i in range(63):
    b = (a >> i) & 1
    print(b)
    x = np.count_nonzero(b)
    x = x * (n - x)
    ans += x * pow(2, i, mod) % mod
print(ans)

Fixed code:
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = 0
for i in range(63):
    b = (a >> i) & 1
    x = np.count_nonzero(b)
    x = x * (n - x)
    ans += x * pow(2, i, mod) % mod
print(ans % mod)
Buggy code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N = ir()
A = np.array(lr(), np.int64)
answer = 0
limit = A.max().bit_length()
for i in range(limit):
    B = (A >> i) & 1
    x = np.count_nonzero(B)
    y = N - x
    add = (x*y) * 2 ** i % MOD
    answer += add

print(answer%MOD)


Fixed code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
MOD = 10 ** 9 + 7
length = int(A.max()).bit_length()
answer = 0
for i in range(length):
    B = (A >> i) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    x *= 2 ** i % MOD
    answer += x

print(answer % MOD)
Buggy code:
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
mod = 10 ** 19 + 7
print(mod)
ans = 0
for i in range(60):
    tmp = (A >> i)
    x = np.count_nonzero(tmp)
    x *= n - x
    ans = (ans + pow(2, i, mod) * x) % mod
print(ans)

Fixed code:
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    tmp = (A >> i) & 1
    x = np.count_nonzero(tmp)
    x *= n - x
    ans = (ans + pow(2, i, mod) * x) % mod
print(ans)
Buggy code:
n = int(input())
a = [format(i, '060b') for i in map(int, input().split())]
divide = 10 ** 9 + 7
ans = []

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

print(sum(ans))

Fixed code:
n = int(input())
divide = 10 ** 9 + 7

a = [format(i, '060b') for i in map(int, input().split())]
ans = []

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

print(sum(ans)%divide)
Buggy code:
import sys
input = sys.stdin.readline

INF = 10 ** 9 + 7
N = int(input())
a = list(map(int, input().split()))
cnt = [0] * 60
for i in a:
    for j in range(60):
        tmp = i >> j
        if tmp != 0:
            cnt[j] += tmp % 2
        else:
            break
ans = 0
#for b in range(60):
#    ans += cnt[b] * (N - cnt[b]) << b
#    ans %= INF
print(ans)

Fixed code:
import sys
input = sys.stdin.readline

INF = 10 ** 9 + 7
N = int(input())
a = list(map(int, input().split()))
cnt = [0] * 60
for i in a:
    for j in range(60):
        tmp = i >> j
        if tmp != 0:
            cnt[j] += tmp % 2
        else:
            break
ans = 0
for b in range(60):
    ans += cnt[b] * (N - cnt[b]) << b
    ans %= INF
print(ans)
Buggy code:
N = int(input())
A = list(map(int, input().split())) 

def sumXOR( arr,  n): 
    sum = 0
    for i in range(0, 64): 
  
        #  Count of zeros and ones 
        zc = 0
        oc = 0
           
        # Individual sum at each bit position 
        idsum = 0
        for j in range(0, n): 
            if (arr[j] % 2 == 0): 
                zc = (zc + 1)
                  
            else: 
                oc = (oc + 1)
            arr[j] = arr[j] / 2 
          
           
        # calculating individual bit sum  
        idsum = (oc * zc * ((1 << i)))
   
        # final sum     
        sum = (sum + idsum)
      
    return sum
  
  
  
  
print(sumXOR(A, N)  % 1000000007)

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

def sumXOR( arr,  n): 
    sum = 0
    for i in range(0, 64): 
  
        #  Count of zeros and ones 
        zc = 0
        oc = 0
           
        # Individual sum at each bit position 
        idsum = 0
        for j in range(0, n): 
            if (arr[j] % 2 == 0): 
                zc = (zc + 1)
                  
            else: 
                oc = (oc + 1)
            arr[j] = (arr[j] >> 1) 
          
           
        # calculating individual bit sum  
        idsum = (oc * zc * ((1 << i))) % 1000000007
   
        # final sum     
        sum = (sum + idsum)
      
    return sum
  
  
  
  
print(sumXOR(A, N)  % 1000000007)
Buggy code:
import numpy as np
mod = 1000000007

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

bit = 1
ans = 0
for n in range(60):
    a_and = a & 1
    cnt_one = np.count_nonzero(a_and)
    ans += (cnt_one * (n - cnt_one) * bit) % mod
    a >>= 1
    bit *= 2
    bit % mod

print(ans)


Fixed code:
import numpy as np
mod = 1000000007

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

bit = 1
ans = 0
for i in range(60):
    a_and = a & 1
    cnt_one = np.count_nonzero(a_and)
    ans += (cnt_one * (n - cnt_one) * bit) % mod
    ans %= mod
    a >>= 1
    bit *= 2
    bit % mod

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

maxdig = 60
mod = 10**9+7

ans = 0
for i in range(60+1):
  cnt1 = 0
  for a in A:
    if (a >> i) & 1:
      cnt1 += 1
  ans += (cnt1*(N-cnt1)*(1<<j))
  ans = ans%mod

print(ans)

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

maxdig = 60
mod = 10**9+7

ans = 0
for i in range(60+1):
  cnt1 = sum([1 for a in A if (a >> i) & 1])
  ans += (cnt1*(N-cnt1)*(1<<i))
  ans = ans%mod

print(ans)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
keta=[0 for i in range(n)]
ans=0
for i in range(n):
  b=a[i]
  cnt=0
  while(b>=1):
    if b%2==1:
      keta[cnt]+=1
    b=b//2
    cnt+=1
#print(keta)
for i in range(len(keta)):
  #print(keta[i])
  ans+=keta[i]*(n-keta[i])*(2**i)
print(ans)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
keta=[0 for i in range(61)]
ans=0
for i in range(n):
  b=a[i]
  cnt=0
  while(b>=1):
    if b%2==1:
      keta[cnt]+=1
    b=b//2
    cnt+=1
#print(keta)
for i in range(61):
  #print(keta[i])
  #print(keta[i]*(n-keta[i])*(2**i))
  ans+=(keta[i]*(n-keta[i])*(2**i))%(1000000007)
while(ans>1000000007):
  ans%=1000000007
print(ans)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
c1_list = [0]*n
for i in range(n):
  b = format(a[i], '060b')
  for j in b:
    if j == "1":
      c1_list[j] += 1
count = 0
for i in range(n):
  count = (count + c1_list[i]*(n-c1_list[i])*2**(60-i)) % 1000000007
print(count)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
c1_list = [0]*60
for i in range(n):
  b = format(a[i], '060b')

  for j in range(len(b)):
    if b[j] == "1":
      c1_list[j] += 1
count = 0
for i in range(60):
  count = (count + c1_list[i]*(n-c1_list[i])*2**(59-i)) % 1000000007
print(count)
Buggy code:
n = int(input())
A = list(map(int, input().split()))

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(n):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)

Fixed code:
n = int(input())
A = list(map(int, input().split()))

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
ar=[0]*60
for i in a:
  for j in range(60):
    if i&(1<<j):
      ar[j]+=1


for i ,j in enumerate(ar):
  b=n-j
  ans+= j*b*1<<i

print(ans)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
ar=[0]*60
for i in a:
  for j in range(60):
    if i&(1<<j):
      ar[j]+=1


for i ,j in enumerate(ar):
  b=n-j
  ans+= j*b*2**i

print(ans%mod)
Buggy code:
import sys

stdin = sys.stdin

mod = 1000000007

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

n = ni()
a = na()

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

print(ans)

Fixed code:
import sys

stdin = sys.stdin

mod = 1000000007

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

n = ni()
a = na()

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

print(ans)