I know, I’m not an advanced coder, but there are some things that might help you with time reduction and more efficiency on competitions.
- Fast I/O
ios_base::sync_with_stdio(false);
cin.tie(NULL);
Put this code in your main function, and it will fasten your cin and cout..
2. Header
#include <bits/stdc++.h>
Many people might know this, but this header file includes most of the stuff you probably need. Also USACO grading computers support this so that’s another time saver.
3. I/O from file
freopen("filename.in", "r", stdin);
freopen("filename.out", "w", stdout);
There are many ways to get input from a file and output to a file, but this is the way I use (I know, I didn’t close it back, but it should be fine)