Computing Olympiad Problem Doubt!

This may be a silly question, but do you set the same compilation flags as the judge when you compile it on your machine?
I had the same code giving me different answers on my machine and the judge ( USACO ). I then found out it was because i wasn’t setting the -O2 optimization flag locally.
So ideally, You should compile with the same flags as on the judge.