Mivik

ametus.h

Dec 13th, 2021
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.07 KB | None | 0 0
  1. #ifndef __AMETUS_H_
  2. #define __AMETUS_H_
  3.  
  4. #include <bits/stdc++.h>
  5.  
  6. // coco: preserve_begin
  7. #define d isdigit(c)
  8. #define g c=t.get();
  9. #define L return
  10. #define K break
  11. #define A(c,a,b)if(c)a else b;
  12. #define I(c,a)if(c)a;
  13. #define Y goto E
  14. struct MI{private:char bb[1 << 14];FILE*f;char*bs,*be;char e;bool o,l;public:MI():f(stdin),bs(0),be(0){}MI(FILE*f):f(f),bs(0),be(0){}
  15. inline operator bool(){L!l;}inline char get(){if(o){o=0;L e;}
  16. #ifdef MIVIK
  17. char c=fgetc(f);I(c==-1,l=1)L c;
  18. #else
  19. I(bs==be,be=(bs=bb)+fread(bb,1,sizeof(bb),f))I(bs==be,{l=1;L-1;})L*bs++;
  20. #endif
  21. }inline void unget(char c){o=1;e=c;}template<class T>inline T read(){T r;*this>r;L r;}template<class T>inline MI&operator>(T&);};template<class T>struct Q{const static bool U=T(-1)>=T(0);inline void operator()(MI&t,T&r)const{r=0;char c;bool y=0;A(U,for(;;){g I(c==-1,Y)I(d,K)},for(;;){g I(c==-1,Y)A(c=='-',{g I(d,{y=1;K;})},I(d,K))})for(;;){I(c==-1,Y)A(d,r=r*10+(c^48);,K)g}t.unget(c);E:;I(y,r=-r)}};template<>struct Q<char>{inline void operator()(MI&t,char&r){int c;for(;;){g I(c==-1,{r=-1;L;})I(!isspace(c),{r=c;L;})}}};template<class T>inline MI&MI::operator>(T&t){Q<T>()(*this,t);L*this;}
  22. #undef d
  23. #undef g
  24. #undef L
  25. #undef K
  26. #undef A
  27. #undef I
  28. #undef Y
  29. template<class T>std::ostream& operator<(std::ostream&out,const T&t){return out<<t;}
  30. #define endl ('\n')
  31. #define P(x) cout<#x" = "<(x)<endl
  32. #define R (cin.read<int>())
  33. #define let const auto
  34. #define with(...) if (__VA_ARGS__; 1)
  35. #define _3(_1, _2, _3, w, ...) w
  36. #define E3(i, l, r) for (int __r = (r), i = (l); i <= __r; ++i)
  37. #define E2(i, n) E3(i, 1, n)
  38. #define E1(n) E2(_, n)
  39. #define E(...) _3(__VA_ARGS__, E3, E2, E1)(__VA_ARGS__)
  40. #define G3(i, l, r) E3(i, l, (r) - 1)
  41. #define G2(i, n) G3(i, 0, n)
  42. #define G1(n) G2(_, n)
  43. #define G(...) _3(__VA_ARGS__, G3, G2, G1)(__VA_ARGS__)
  44. #ifdef MIVIK
  45. #include <fmt/ranges.h>
  46. template<class...Args>
  47. inline void debug(const char *msg, Args&&...args) { fmt::print(stderr, msg, std::forward<Args>(args)...); fputc('\n', stderr); }
  48. #else
  49. #define debug(...)
  50. #endif
  51. // coco: preserve_end
  52.  
  53. using std::cout;
  54.  
  55. #endif
Advertisement
Add Comment
Please, Sign In to add comment