This is an easy code to stress test. Generate some N values from 10^{3} to 10^{6}. You can get the correct code from editorial. Try to see which values differ.
I did the same and I am putting the values for N which your answer differs from the correct value.
N = 100572, Actual Solution = 29458, Your Solution = 29457
N = 101487, Actual Solution = 29726, Your Solution = 29725
N = 102303, Actual Solution = 29965, Your Solution = 29964
N = 102880, Actual Solution = 30134, Your Solution = 30133
N = 103119, Actual Solution = 30204, Your Solution = 30203
N = 103696, Actual Solution = 30373, Your Solution = 30372
N = 103935, Actual Solution = 30443, Your Solution = 30442
N = 104512, Actual Solution = 30612, Your Solution = 30611
N = 105328, Actual Solution = 30851, Your Solution = 30850
N = 106243, Actual Solution = 31119, Your Solution = 31118
N = 106820, Actual Solution = 31288, Your Solution = 31287 etc.
From here figure out that there might be error in your floor function. So change your roots function
. Here is the modified AC Solution - https://www.codechef.com/viewsolution/38011692