Tips.cpp 751 B

12345678910111213141516171819202122232425
  1. // change stack size, in bytes
  2. #pragma comment(linker, "/STACK:33777216") // no spaces !
  3. // regex
  4. regex reg(R"[a-z]+");
  5. string str("couCOU");
  6. bool match = regex_match(str, reg);
  7. // builtins
  8. __gcd(x, y);
  9. // for __builtin_*, add suffix l for long, ll for long long
  10. __builtin_ffs(int);// 1 + least significant 1-bit
  11. // __builtin_ffs(1010b) = 2
  12. // __builtin_ffs(0) = -1
  13. __builtin_clz(unsigned int) // number of leading 0-bits
  14. // __builtin_clz(0..010100b) = 27
  15. // __builtin_clz(0) is undefined
  16. __builtin_ctz(unsigned int) // number of trailing 0-bits
  17. // __builtin_ctz(0..010100b) = 2
  18. // __builtin_ctz(0) is undefined
  19. __builtin_popcount(int) // number of 1-bits
  20. // __builtin_popcount(0110b) = 2
  21. // desynchronise standard i/o
  22. ios::sync_with_stdio(false);