Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
I found the second link to be the most help.
<bits/stdc++.h> is not a standard C++ header file and it makes it difficult to compile or run the program with a file that most people do not have.
I do not mean to be rude and do not take this the wrong way, but optimizate is not a proper word and I am not sure what yo are looking for.
Along with the proper code tags and indenting a fwe blank lines would help to make the code easier to read.
With an attitude like that nothing is what you will get in abundance.
Reporting the one person trying to help you is the wrong approach. You may not have liked salem c's answers, but his point was to try and get you to think about some different in how the program could work.
Open your eyes, people.
@minimum is obviously a troll.
Couldn't be more obvious.
Anyway, in future if someone responds to this type of question, they should start (or end) their post with a copy of the question. That way it can't be deleted.