Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    sum = 0

    for i in range(60):
        count_1 = 0
        for a in a_list:
            bin_a = format(a, "b").zfill(60)
            if bin_a[59-i] == "1":
                count_1 += 1

        sum += 2 ** i * count_1 * (N - count_1)

    print(sum % mod)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    t = [0]*60

    for a in a_list:
        for count, i in enumerate(reversed(format(a, "b"))):
            if i == "1":
                t[count] += 1

    sum = 0
    for i, count in enumerate(t):
        sum += 2 ** i * count * (N - count)
    print(sum % mod)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    sum = 0

    for i in range(60):
        count_1 = 0
        for a in a_list:
            bin_a = format(a, "b").zfill(60)
            if bin_a[59-i] == "1":
                count_1 += 1

        sum += 2 ** i * count_1 * (N - count_1)

    print(sum % mod)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    t = [0]*60

    for a in a_list:
        for count, i in enumerate(reversed(format(a, "b"))):
            if i == "1":
                t[count] += 1

    sum = 0
    for i, count in enumerate(t):
        sum += 2 ** i * count * (N - count)
    print(sum % mod)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    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):
            if a_list[i] == a_list[j]:
                continue
            sum += a_list[i] ^ a_list[j]

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


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    t = [0]*60

    for a in a_list:
        for count, i in enumerate(reversed(format(a, "b"))):
            if i == "1":
                t[count] += 1

    sum = 0
    for i, count in enumerate(t):
        sum += 2 ** i * count * (N - count)
    print(sum % mod)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    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):
           sum += a_list[i] ^ a_list[j]

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


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    t = [0]*60

    for a in a_list:
        for count, i in enumerate(reversed(format(a, "b"))):
            if i == "1":
                t[count] += 1

    sum = 0
    for i, count in enumerate(t):
        sum += 2 ** i * count * (N - count)
    print(sum % mod)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    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):
           sum += a_list[i] ^ a_list[j]

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


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    t = [0]*60

    for a in a_list:
        for count, i in enumerate(reversed(format(a, "b"))):
            if i == "1":
                t[count] += 1

    sum = 0
    for i, count in enumerate(t):
        sum += 2 ** i * count * (N - count)
    print(sum % mod)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    a_list = list(map(int, input().split()))

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

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


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    t = [0]*60

    for a in a_list:
        for count, i in enumerate(reversed(format(a, "b"))):
            if i == "1":
                t[count] += 1

    sum = 0
    for i, count in enumerate(t):
        sum += 2 ** i * count * (N - count)
    print(sum % mod)


if __name__ == '__main__':
    main()