c++ macros for competitive programming code example

Example: use macro in competitive programing c++

#include <bits/stdc++.h> // Include every standard library
using namespace std;
#define FASTIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) 
#define MULTIPLE_TEST int t; cin>>t; while(t--) //for multilple cases problems
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define FOR(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FER(i,L,R) for (int i = L; i <= R; i++)
#define FOD(i,L,R) for (int i = L; i > R; i--)
#define FED(i,L,R) for (int i = L; i >= R; i--)
#define clr(a,x) memset(a,x,sizeof(a)) //set elements of array to some value
#define all(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define INF 0x7fffffff 
#define ll long long //data types used often, but you don't want to type them time by time
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back 
#define gcd 
#define MAXN 10005
#define MOD 1000000007 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

Tags:

Cpp Example