Checkout the editorial of the problem here
Basically N can be written as:
So now simply check if x is greater than 0 and RHS is a whole number. If true YES, else NO.
N-2021y > 0
Run a loop of y from 1 to floor(N/2021) and check if any integer solution of x exists.