I am getting TLE on the codeforces problem Two Divisors from the recent educational contest. Link to the problem:- https://codeforces.me/problemset/problem/1366/D. Link to my submission:- https://codeforces.me/contest/1366/submission/83516292. Please suggest ways to optimize it.
Thank you.