import time
from itertools import product

def with_nested_loop():
	s = 0
	for i in range(5000):
		for j in range(5000):
			s += i / (j + 1)
	
	print(s)
	
def with_product():
	s = 0
	for i, j in product(range(5000), range(5000)):
		s += i / (j + 1)
	
	print(s)

start = time.time()
with_nested_loop()
elapsed = time.time() - start
print('{:.6f} sec'.format(elapsed))

start = time.time()
with_product()
elapsed = time.time() - start
print('{:.6f} sec'.format(elapsed))
