-
Notifications
You must be signed in to change notification settings - Fork 12
/
cpp-template.cpp
42 lines (42 loc) · 1.81 KB
/
cpp-template.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// no of elements less than or equal to x upperbound-v.end
// no of elements less than x lowerbound - v.begin
// fflush(stdout) ("%I64d")
#include <bits/stdc++.h>
using namespace std;
/*ONLY FOR GNU*/
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*
* tree.find_by_order(key) == gives iterator at key th position in tree...arr[i]
* tree.order_of_key(key)== number of elements that are smaller than key...i for arr[i]
* GNU SPECIFIC ENDS
*/
const int inf = 1<<28;
typedef long long lli;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
#define sc scanf /*remember that %c %n %[] does NOT consume whitespaces*/
#define scd(a) scanf("%d", &a)
#define scs(a) scanf("%s", a)
#define pr printf
#define prd(a) printf("%d\n", a)
#define fr first
#define sec second
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end()
#define mmset(a, b) memset(a, b, sizeof(a))
void inputVec(vi&v) {for (auto&i : v)scd(i);}
void printVec(vi&v) {for (auto&i : v)prd(i);}
void printMat(vvi& mat) {for (auto&v : mat) {for (auto&x : v)cout << x << " ";} cout << endl;}
int left(int i) {return i << 1;}
int right(int i) {return (i << 1) + 1;}
int mid(int a, int b) {return (a + b) >> 1;}
int mid1(int a, int b) {return ((a+b)>>1)+1;}
void iofile() {freopen(R"(../in)", "r", stdin);freopen(R"(../out)", "w", stdout);}
/*************************/
const int D = (int)4e4+5;