Hi everyone,
I'm new to competitive programming and I use C++. I've solved about 40 problems on Codeforces and CSES.
I saw many people use templates like this:
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
What I understand so far
Macros just replace text before compilation, so they save typing. For example, sort(all(v)) instead of sort(v.begin(), v.end()).
What confuses me
I read that this macro is dangerous:
cpp #define sq(x) x * xsq(a + b)becomesa + b * a + b, which is wrong. I fixed it with((x) * (x)), but I'm not sure when this kind of bug can appear in a real contest.I heard that
using ll = long long;is better than#define ll long long. Is there a real difference in practice, or is it only about style?
My question: Do you recommend that beginners use macros, or only using ll = long long;? Which macros do you actually use?
Thanks for reading, and sorry for any English mistakes!



