1. Basic Arithmetic Formulas
- Sum of first $$$n$$$ natural numbers:
- Sum of squares:
- Sum of cubes:
2. Modular Arithmetic
- Addition:
- Multiplication:
- Modular inverse (when $$$m$$$ is prime):
3. GCD and LCM
4. Combinatorics
5. Bit Manipulation
- Power of 2 check:
- XOR properties:
6. Prefix Sums
7. Geometry
- Distance formula:
- Triangle area:
8. Pigeonhole Principle
If $$$n+1$$$ objects are placed into $$$n$$$ boxes, at least one box contains more than one object.









also , n%a = n-a(n//a)
This helps convert mod constraints into intervals. For example, n%a≤k⇒n∈[aq,aq+k] where q=n//a.
Very helpful for counting problems and block decomposition.
in the power of 2 check.
if n==0, it will be true, so we have to check if n>0 first.
wtf why is this blog downrated?
maybe because [n & (n-1) = 0 ] fails when number's domain is W or Z and only works for N domain
or we can say for n<1 it won't work a beginner will see the blog and try using it on 0(domain Z(W)) , and his code will not work
still, the entire rest of the blog is correct and very useful
it is grey effect
people usually downvote blogs just because they are written by a grey