Buggy python submission (verdict: Runtime Error):
def main():
    num = int(input())
    gg = ((
        (quotient := num // divisor) + 1) * quotient * divisor // 2
        for divisor in range(1, num + 1))
    print(sum(gg))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    num = int(input())
    ans = 0

    for divisor in range(1, num + 1):
        quotient = num // divisor
        ans += (quotient + 1) * quotient * divisor // 2

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    num = int(input())
    ans = 0

    for div in range(1, num + 1):
        for i in range(div, num + 1):
            if i % div == 0:
                ans += i

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    num = int(input())
    ans = 0

    for divisor in range(1, num + 1):
        quotient = num // divisor
        ans += (quotient + 1) * quotient * divisor // 2

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    num = int(input())
    ans = 0

    for div in range(1, num + 1):
        for i in range(1, num + 1):
            if i % div == 0:
                ans += i

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    num = int(input())
    ans = 0

    for divisor in range(1, num + 1):
        quotient = num // divisor
        ans += (quotient + 1) * quotient * divisor // 2

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import math
from collections import defaultdict


def prime_factorize(n):
    """素因数分解する。"""
    def facs():
        """試し割り法における割る数を生成する。"""
        yield 2
        max_prime = int(pow(n, 0.5)) + 1
        for x in range(3, max_prime, 2):
            yield x

    ans = defaultdict(int)
    for fac in facs():
        while n % fac == 0:
            ans[fac] += 1
            n //= fac
        if pow(fac, 2) > n:
            break
    if n != 1:
        ans[n] += 1
    return ans


def count_divs(x):
    di = prime_factorize(x)
    ans = 1
    for exp in di.values():
        ans *= (exp + 1)
    return ans


def co_primes(x):
    """Return co-prime divisors of x."""
    for a in range(int(pow(x, 0.5)) + 1, 0, -1):
        if x % a == 0:
            b = x // a
        else:
            continue
        if math.gcd(a, b) == 1:
            return a, b


def main():
    num = int(input())
    array = [0] * (num + 1)

    def func(x):
        if x == 1:
            return 1
        elif x == 2:
            return 4
        a, b = co_primes(x)
        if min(a, b) == 1:
            # x is prime
            tmp = max(a, b)
            return tmp * count_divs(tmp)
        else:
            return array[a] * array[b]

    ans = 0
    for x in range(num):
        x += 1
        tmp = func(x)
        array[x] = tmp
        ans += tmp

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    num = int(input())
    ans = 0

    for divisor in range(1, num + 1):
        quotient = num // divisor
        ans += (quotient + 1) * quotient * divisor // 2

    print(ans)


if __name__ == '__main__':
    main()