I am stuck, not able to implement the max statement

The error is due to the name conflict of max.

You have defined max as a macro here, thus, “max” has become an expression now.
Thus, you can’t access the predefined function with same name which is “max()”.

This explains the error, change the name of macro or remove/comment it to run “max()” in your code

//#define max 1000002

Hope, this would help.
Give a like, if you are satisfied.