Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


if __name__=='__main__':
    main()


Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    bin_a=[[0] * n for i in range(60)]
    cnt1=[0]*60
    for i in range(n):
        tmp=str(bin(a[i]))
        # print(a[i])
        # print(len(tmp))
        for j in range(len(tmp)-2):
            if j==len(tmp)-2:
                break
            # print(tmp[len(tmp)-i-1])
            bin_a[j][i]=int(tmp[len(tmp)-j-1])
            cnt1[j]+=int(tmp[len(tmp)-j-1])

    for i in range(60):
        # cnt1=sum(bin_a[i])
        # cnt0=n-cnt1
        ans+=cnt1[i]*(n-cnt1[i])*2**i%MOD
    print(ans%MOD)

if __name__=='__main__':
    main()


Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    bin_a=[[0] * n for i in range(60)]
    cnt1=[0]*60
    for i in range(n):
        tmp=str(bin(a[i]))
        # print(a[i])
        # print(len(tmp))
        for j in range(len(tmp)-2):
            if tmp[len(tmp)-j-1] == 'b':
                break
            # print(tmp[len(tmp)-i-1])
            bin_a[j][i]=int(tmp[len(tmp)-j-1])
            cnt1[j]+=int(tmp[len(tmp)-j-1])

    for i in range(60):
        # cnt1=sum(bin_a[i])
        # cnt0=n-cnt1
        ans+=cnt1[i]*(n-cnt1[i])*2**i%MOD
    print(ans%MOD)

if __name__=='__main__':
    main()


Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    leng=0
    bin_a=[[0] * n for i in range(60)]
    for i in range(n):
        tmp=str(bin(a[i]))
        # print(a[i])
        # print(len(tmp))
        leng=max(leng,len(tmp))
        for j in range(len(tmp)-2):
            if tmp[len(tmp)-j-1] == 'b':
                break
            # print(tmp[len(tmp)-i-1])
            bin_a[j][i]=int(tmp[len(tmp)-j-1])

    for i in range(leng):
        cnt1=sum(bin_a[i])
        cnt0=n-cnt1
        ans+=cnt1*cnt0*2**i%MOD
    print(ans%MOD)

if __name__=='__main__':
    main()


Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    bin_a=[[0] * n for i in range(60)]
    for i in range(n):
        tmp=str(bin(a[i]))
        # print(a[i])
        # print(len(tmp))
        for j in range(len(tmp)-2):
            if tmp[len(tmp)-j-1] == 'b':
                break
            # print(tmp[len(tmp)-i-1])
            bin_a[j][i]=int(tmp[len(tmp)-j-1])

    for i in range(60):
        cnt1=sum(bin_a[i])
        cnt0=n-cnt1
        ans+=cnt1*cnt0*2**i%MOD
    print(ans%MOD)

if __name__=='__main__':
    main()


Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    bin_a=[[0] * n for i in range(60)]
    for i in range(n):
        tmp=str(bin(a[i]))
        # print(a[i])
        # print(len(tmp))
        for j in range(len(tmp)-2):
            if tmp[len(tmp)-j-1] == 'b':
                break
            # print(tmp[len(tmp)-i-1])
            bin_a[j][i]=int(tmp[len(tmp)-j-1])

    for i in range(60):
        cnt1=sum(bin_a[i])
        cnt0=n-cnt1
        ans+=cnt1*cnt0*2**i%MOD
    print(ans%MOD)

if __name__=='__main__':
    main()


Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    for i in range(0,n-1):
        for j in range(i+1,n):
            temp=(a[i] ^ a[j])
            ans+=temp%MOD
    print(ans%MOD)
if __name__=='__main__':
    main()


Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


if __name__=='__main__':
    main()