fork(1) download
  1. /**
  2.  * My fuckin' trash template for CP.
  3.  * Update:
  4.  * - Too much pragma.
  5.  * - (Copied) new function for faster reading / writing (or not)
  6.  * To read / write: just use cin / cout
  7.  **/
  8.  
  9. /**
  10.  * author:
  11.  * date:
  12.  **/
  13.  
  14. #pragma GCC optimize("O3")
  15. #pragma GCC optimize("O1")
  16. #pragma GCC optimize("O1")
  17. #pragma GCC target("avx2")
  18. #pragma GCC optimize("unroll-loops")
  19. #pragma GCC target("avx")
  20. #pragma GCC optimize(3)
  21. #pragma GCC optimize("Ofast")
  22. #pragma GCC optimize("inline")
  23. #pragma GCC optimize("-fgcse")
  24. #pragma GCC optimize("-fgcse-lm")
  25. #pragma GCC optimize("-fipa-sra")
  26. #pragma GCC optimize("-ftree-pre")
  27. #pragma GCC optimize("-ftree-vrp")
  28. #pragma GCC optimize("-fpeephole2")
  29. #pragma GCC optimize("-ffast-math")
  30. #pragma GCC optimize("-fsched-spec")
  31. #pragma GCC optimize("-falign-jumps")
  32. #pragma GCC optimize("-falign-loops")
  33. #pragma GCC optimize("-falign-labels")
  34. #pragma GCC optimize("-fdevirtualize")
  35. #pragma GCC optimize("-fcaller-saves")
  36. #pragma GCC optimize("-fcrossjumping")
  37. #pragma GCC optimize("-fthread-jumps")
  38. #pragma GCC optimize("-freorder-blocks")
  39. #pragma GCC optimize("-fschedule-insns")
  40. #pragma GCC optimize("inline-functions")
  41. #pragma GCC optimize("-ftree-tail-merge")
  42. #pragma GCC optimize("-fschedule-insns2")
  43. #pragma GCC optimize("-fstrict-aliasing")
  44. #pragma GCC optimize("-falign-functions")
  45. #pragma GCC optimize("-fcse-follow-jumps")
  46. #pragma GCC optimize("-fsched-interblock")
  47. #pragma GCC optimize("-fpartial-inlining")
  48. #pragma GCC optimize("no-stack-protector")
  49. #pragma GCC optimize("-freorder-functions")
  50. #pragma GCC optimize("-findirect-inlining")
  51. #pragma GCC optimize("-fhoist-adjacent-loads")
  52. #pragma GCC optimize("-frerun-cse-after-loop")
  53. #pragma GCC optimize("inline-small-functions")
  54. #pragma GCC optimize("-finline-small-functions")
  55. #pragma GCC optimize("-ftree-switch-conversion")
  56. #pragma GCC optimize("-foptimize-sibling-calls")
  57. #pragma GCC optimize("-fexpensive-optimizations")
  58. #pragma GCC optimize("inline-functions-called-once")
  59. #pragma GCC optimize("-fdelete-null-pointer-checks")
  60. #pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,mmx,abm")
  61.  
  62. #include<bits/stdc++.h>
  63. using namespace std;
  64.  
  65. static struct FastInput {
  66. static constexpr int BUF_SIZE = 1 << 20;
  67. char buf[BUF_SIZE];
  68. size_t chars_read = 0;
  69. size_t buf_pos = 0;
  70. FILE *in = stdin;
  71. char cur = 0;
  72.  
  73. inline char get_char() {
  74. if (buf_pos >= chars_read) {
  75. chars_read = fread(buf, 1, BUF_SIZE, in);
  76. buf_pos = 0;
  77. buf[0] = (chars_read == 0 ? -1 : buf[0]);
  78. }
  79. return cur = buf[buf_pos++];
  80. }
  81.  
  82. inline void tie(int) {}
  83.  
  84. inline explicit operator bool() {
  85. return cur != -1;
  86. }
  87.  
  88. inline static bool is_blank(char c) {
  89. return c <= ' ';
  90. }
  91.  
  92. inline bool skip_blanks() {
  93. while (is_blank(cur) && cur != -1) {
  94. get_char();
  95. }
  96. return cur != -1;
  97. }
  98.  
  99. inline FastInput& operator>>(char& c) {
  100. skip_blanks();
  101. c = cur;
  102. return *this;
  103. }
  104.  
  105. inline FastInput& operator>>(string& s) {
  106. if (skip_blanks()) {
  107. s.clear();
  108. do {
  109. s += cur;
  110. } while (!is_blank(get_char()));
  111. }
  112. return *this;
  113. }
  114.  
  115. template <typename T>
  116. inline FastInput& read_integer(T& n) {
  117. // unsafe, doesn't check that characters are actually digits
  118. n = 0;
  119. if (skip_blanks()) {
  120. int sign = +1;
  121. if (cur == '-') {
  122. sign = -1;
  123. get_char();
  124. }
  125. do {
  126. n += n + (n << 3) + cur - '0';
  127. } while (!is_blank(get_char()));
  128. n *= sign;
  129. }
  130. return *this;
  131. }
  132.  
  133. template <typename T>
  134. inline typename enable_if<is_integral<T>::value, FastInput&>::type operator>>(T& n) {
  135. return read_integer(n);
  136. }
  137.  
  138. #if !defined(_WIN32) | defined(_WIN64)
  139. inline FastInput& operator>>(__int128& n) {
  140. return read_integer(n);
  141. }
  142. #endif
  143.  
  144. template <typename T>
  145. inline typename enable_if<is_floating_point<T>::value, FastInput&>::type operator>>(T& n) {
  146. // not sure if really fast, for compatibility only
  147. n = 0;
  148. if (skip_blanks()) {
  149. string s;
  150. (*this) >> s;
  151. sscanf(s.c_str(), "%lf", &n);
  152. }
  153. return *this;
  154. }
  155. } fast_input;
  156.  
  157. #define cin fast_input
  158.  
  159. static struct FastOutput {
  160. static constexpr int BUF_SIZE = 1 << 20;
  161. char buf[BUF_SIZE];
  162. size_t buf_pos = 0;
  163. static constexpr int TMP_SIZE = 1 << 20;
  164. char tmp[TMP_SIZE];
  165. FILE *out = stdout;
  166.  
  167. inline void put_char(char c) {
  168. buf[buf_pos++] = c;
  169. if (buf_pos == BUF_SIZE) {
  170. fwrite(buf, 1, buf_pos, out);
  171. buf_pos = 0;
  172. }
  173. }
  174.  
  175. ~FastOutput() {
  176. fwrite(buf, 1, buf_pos, out);
  177. }
  178.  
  179. inline FastOutput& operator<<(char c) {
  180. put_char(c);
  181. return *this;
  182. }
  183.  
  184. inline FastOutput& operator<<(const char* s) {
  185. while (*s) {
  186. put_char(*s++);
  187. }
  188. return *this;
  189. }
  190.  
  191. inline FastOutput& operator<<(const string& s) {
  192. for (int i = 0; i < (int) s.size(); i++) {
  193. put_char(s[i]);
  194. }
  195. return *this;
  196. }
  197.  
  198. template <typename T>
  199. inline char* integer_to_string(T n) {
  200. // beware of TMP_SIZE
  201. char* p = tmp + TMP_SIZE - 1;
  202. if (n == 0) {
  203. *--p = '0';
  204. } else {
  205. bool is_negative = false;
  206. if (n < 0) {
  207. is_negative = true;
  208. n = -n;
  209. }
  210. while (n > 0) {
  211. *--p = (char) ('0' + n % 10);
  212. n /= 10;
  213. }
  214. if (is_negative) {
  215. *--p = '-';
  216. }
  217. }
  218. return p;
  219. }
  220.  
  221. template <typename T>
  222. inline typename enable_if<is_integral<T>::value, char*>::type stringify(T n) {
  223. return integer_to_string(n);
  224. }
  225.  
  226. #if !defined(_WIN32) || defined(_WIN64)
  227. inline char* stringify(__int128 n) {
  228. return integer_to_string(n);
  229. }
  230. #endif
  231.  
  232. template <typename T>
  233. inline typename enable_if<is_floating_point<T>::value, char*>::type stringify(T n) {
  234. sprintf(tmp, "%.17f", n);
  235. return tmp;
  236. }
  237.  
  238. template <typename T>
  239. inline FastOutput& operator<<(const T& n) {
  240. auto p = stringify(n);
  241. for (; *p != 0; p++) {
  242. put_char(*p);
  243. }
  244. return *this;
  245. }
  246. } fast_output;
  247.  
  248. #define cout fast_output
  249. #define endl '\n'
  250.  
  251. int main(){
  252. int x;
  253. cin >> x;
  254. cout << x;
  255. }
  256.  
Success #stdin #stdout 0.01s 5536KB
stdin
15
stdout
15