Getting Wrong answer in VIVEK AND FACTORS

ques link : https://hack.codingblocks.com/contests/c/547/656
code link : https://ide.codingblocks.com/s/43661

I am making a seive like structure storing sums of factors of first 1E6 numbers and then simply searching the value of s in it.

https://ide.codingblocks.com/s/43821

I have made a change in the search part of the code. And it passes all the cases.
If multiple numbers have same sum, we are required to output the maximum number

https://ide.codingblocks.com/s/43822

This is my submission for the question
This solves the problem in better time complexity. Your code will produce a TLE for large input files