C/C++便利マクロ
code:macro.c
#define PRINT(fmt, x) printf("%s = " fmt,#x,(x))
#define PRINTLN(fmt, x) printf("%s = " fmt "\n",#x,(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
code:macro.cpp
#define PRINTLN(x) std::cout << (x) << '\n'
#define PRINT_HXLN(h,x) std::cout << (h) << ": " << (x) << '\n'
#define PRINT_XLN(x) std::cout << #x << ": " << (x) << '\n'
#define PRINT_HXTLN(h,x,t) std::cout << (h) << ": " << (x) << (t) << '\n'
// ref: https://sigcpp.github.io/2020/07/10/variadic-print-macros
参考
Variadic print macros | sigcpp
c - Printing name and value of a macro - Stack Overflow
競技プログラミング テクニック集 in C++ - HackMD
競プロC++テンプレートまとめ #C++ - Qiita
関連
競技プログラミング
#C/C++