Skip to content

Template Contest

Small template with the most essential things to be typed at the start of the contest and used for all problems.

Code

Template Contest
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'
#define V vector

#define all(x) begin(x),end(x)
#define sz(x) (int)size(x)
#define loop(i,n) for (int i = 0; i < (n); i++)

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

}

Modular Arithmetic

Modular Arithmetic for Babies
int mul(int a, int b) { return (a * b) % MOD; }
int add(int a, int b) { return (a + b) % MOD; }
int fexp(int b, int e=MOD-2) {
  b %= MOD;
  int ans = 1;
  while (e) {
    if (e & 1) ans = mul(ans, b);
    e >>= 1;
    b = mul(b, b);
  }
  return ans;
}