Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    n = int(np.log2(np.max(A)))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

from math import * 

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

    ans = 0
    MOD = 10**9+7
    k = 1
    n = ceil(log2(max(A)))
    for i in range(n):
        c = 0
        for j in range(N):
            c += A[j] & 1
            A[j] >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

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

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

    ans = 0
    MOD = 10**9+7
    k = 1
    for i in range(60):
        c = 0
        for j in range(N):
            c += A[j] & 1
            A[j] >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

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

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    MOD = 10**9 + 7
    
    N = int(input())
    A = list(map(int, input().split()))
    
    import numpy as np
    
    count = np.zeros((N+1, 60, 2), dtype='int')
    
    b = np.zeros(60, dtype='int')
    b[0] = 1
    for i in range(1, 60): b[i] = b[i-1] * 2 % MOD
    
    for i in range(1, N+1):
        count[i] = np.copy(count[i-1])
        a = A[i-1]
        for j in range(60):
            count[i][j][a%2] += 1
            a >>= 1
        
    ans = 0
    
    n = np.zeros(60, dtype='int')
    for i in range(1, N):
        c = count[N]-count[i]
        a = A[i-1]
        for j in range(60):
            n[j] = c[j][0] if a % 2 else c[j][1]
            a >>= 1
        ans = (ans + np.sum(n*b)) % MOD
        
    print(ans)
    
if __name__ == '__main__':
    main()    

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline

def main():
    MOD = 10**9+7
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    k = 1
    
    for i in range(60):
        c = 0
        for j in range(N):
            if A[j] & 1: c += 1
            A[j] = A[j] >> 1
        ans += c * (N-c) * k
        ans %= MOD
        k *= 2
            
    print(ans)

if __name__ == '__main__':
    main()  

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(60):
    c = 0
    for a in A:
        if (a>>i) & 1: c += 1
        
    ans += (c * (N-c) % MOD * 2 **i % MOD) % MOD
        
print(ans%MOD)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import ceil, log2

input = sys.stdin.readline

def main():
    MOD = 10**9 + 7
    
    N = int(input())
    A = list(map(int, input().split()))
    K = ceil(log2(max(max(A), 1)))
    nums = [[0,0] for i in range(K)]
    ks = [(i, 2**i) for i in range(K)]
    
    for i, a in enumerate(A):
        for j, k in ks:
            n = a & k > 0
            nums[j][n] += 1
    ans = 0
    
    for a in A:
        for j, k in ks:
            n = a & k > 0
            nums[j][n] -= 1
            ans += k * nums[j][not n] % MOD
            
    print(ans%MOD)

if __name__ == '__main__':
    main()



Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
from math import ceil, log2

input = sys.stdin.readline

def main():
    MOD = 10**9 + 7
    
    N = int(input())
    A = list(map(int, input().split()))
    K = ceil(log2(max(A)))
    
    nums = [[0,0] for i in range(K)]
    ks = [(i, 2**i) for i in range(K)]
    
    A_ = [[] for i in range(N)]
    
    for i, a in enumerate(A):
        for j, k in ks:
            n = a & k > 0
            A_[i].append(n)
            nums[j][n] += 1
            
    ans = 0
    
    for a in A_:
        for i, n in enumerate(a):
            nums[i][n] -= 1
            ans += ks[i][1] * nums[i][not n] % MOD
            
    print(ans%MOD)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()