Skip to content

Instantly share code, notes, and snippets.

@imjching
Created January 30, 2019 17:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imjching/2e1c5b2fab12c1dc5658c257288edb43 to your computer and use it in GitHub Desktop.
Save imjching/2e1c5b2fab12c1dc5658c257288edb43 to your computer and use it in GitHub Desktop.
Competitive Programming Template
// Start of template
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned llu;
typedef long long ll;
typedef long double ld;
typedef pair<double, double> dd;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<string> vstr;
typedef vector<vstr> vvstr;
typedef vector<char> vc;
typedef vector<bool> vb;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
#define endl1 endl
#define endl '\n'
#ifdef TESTING
#define DEBUG fprintf(stderr, "---- Testing ----\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG
#define VALUE(x)
#define debug(...)
#endif
#define travprint(x) TRAV(i, x) { cout << i << " "; }; cout << endl;
#define REP(i, a, b) for (int i = a; i < (int) (b); ++i)
#define RREP(i, a, b) for (int i = a; i >= (int) (b); --i)
#define REPL(i, a, b) for (ll i = a; i < (ll) (b); ++i)
#define RREPL(i, a, b) for (ll i = a; i >= (ll) (b); --i)
#define TRAV(a, v) for (auto &a : v)
#define ALL(x) x.begin(), x.end()
#define ALLA(arr, sz) arr, arr + sz
#define RALL(x) x.rbegin(), x.rend()
#define SIZE(x) (int) (x).size()
#define RESET(a, b) memset(a, b, sizeof(a))
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define TC(t) while (t--)
#define GetInt read<int> // %d
#define GetLL read<ll> // %lld
#define PERMUTE next_permutation
#define INF 1e9
#define EPS 1e-9
#define umap unordered_map
#define uset unordered_set
#define mp make_pair
#define pb push_back
// ----- I/O methods -----
inline string GetLine() {
string s;
while (!feof(stdin)) {
char c = fgetc(stdin);
if (c <= 0) continue;
if (c == 13) continue;
if (c == 10) return s;
s += c;
}
return s;
}
inline string GetString(void) {
char x[1000005];
scanf("%s", x); string s = x;
return s;
}
template <typename T> inline void write(T x) {
if (x < 0) {
x = -x;
putchar_unlocked('-');
}
int i = 21;
char output_buffer[22];
output_buffer[21] = '\n';
do {
output_buffer[--i] = (x % 10) + '0';
x /= 10;
} while (x);
do {
putchar_unlocked(output_buffer[i]);
} while (output_buffer[i++] != '\n');
}
template <typename T> inline T read() {
T n = 0, s = 1;
char ip = getchar_unlocked();
for (; ip < '0' || ip > '9'; ip = getchar_unlocked()) {
if (ip == '-') {
s = -1, ip = getchar_unlocked();
break;
}
}
for (; ip >= '0' && ip <= '9'; ip = getchar_unlocked()) {
n = (n << 3) + (n << 1) + (ip - '0');
}
return n * s;
}
inline void FastIO(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL); // flush cout before cin accepts input
}
// ----- End of I/O methods -----
inline void OPEN(string s) {
freopen((s + ".in").c_str(), "r", stdin);
// freopen((s + ".out").c_str(), "w", stdout);
}
// End of template
int t;
int main() {
#ifdef TESTING
OPEN("input");
#endif
t = GetInt();
TC(t) {
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment