Jane Street Interview Question

hard mental math