make 14.py faster with memoization
yeah, 16