-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.cpp
105 lines (92 loc) · 2.5 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include<bits/stdc++.h>
using namespace std;
/***************************** All Required define Pre-Processors and typedef Constants ***********************************/
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ll long long
#define ull unsigned long long
#define ld long double
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef map<int,int> mpii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define PB push_back
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
/****************************** Some Useful Templates function ************************************/
template<typename T> T gcd(T a, T b){if(a==0)return b;if(b==0)return a;if(a==1||b==1)return 1;
if(a==b)return a;if(a>b)return gcd(b,a%b);else return gcd(a,b%a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
/****************** FAST IO *******************************/
template <typename T> inline void write(T x)
{
int i = 20;
char buf[21];
// buf[10] = 0;
buf[20] = '\n';
do
{
buf[--i] = x % 10 + '0';
x/= 10;
}while(x);
do
{
putchar(buf[i]);
} while (buf[i++] != '\n');
}
template <typename T> inline T readInt()
{
T n=0,s=1;
char p=getchar();
if(p=='-')
s=-1;
while((p<'0'||p>'9')&&p!=EOF&&p!='-')
p=getchar();
if(p=='-')
s=-1,p=getchar();
while(p>='0'&&p<='9') {
n = (n<< 3) + (n<< 1) + (p - '0');
p=getchar();
}
return n*s;
}