forked from rayhan50001/Code_Library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmytemplate.cpp
More file actions
216 lines (215 loc) · 4.96 KB
/
mytemplate.cpp
File metadata and controls
216 lines (215 loc) · 4.96 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#include<iostream>
#include<cstdio>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
#include<deque>
#include<iterator>
#include<assert.h>
#include<bitset>
#include<climits>
#include<ctime>
#include<complex>
#include<bits/stdc++.h>
//#include<unordered_map>
using namespace std;
//define for shortcut
#define mem(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
#define sz(A) A.size()
#define clr(a) memset(a,0,sizeof(a))
#define pb push_back
#define pi acos(-1.0)
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define vs vector<string>
#define vi vector<int>
#define vc vector<char>
#define sts set<string>
#define sti set<int>
#define stc set<char>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define ull unsigned long long
#define ll long long
#define for1(i,a,b) for(int i=a;i<=b;i++)
#define rfor1(i,a,b) for(int i=a;i>=b;i--)
#define rfor0(i,a,b) for(int i=a-1;i>b;i--)
#define for0(i,a) for(int i=0;i<a;i++)
//read input
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d%d",&a,&b)
#define sf3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define sfll2(a,b) scanf("%lld%lld",&a,&b)
#define sfll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define ss(a) scanf("%s",&a)
#define sc(a) scanf("%c",&a)
#define sd(a) scanf("%lf",&a)
#define pf(a) printf("%d",a)
#define pfll(a) printf("%lld",a)
#define pfd(a) printf("%.17f",a)
#define pc(a) printf("%c",a)
#define ps(a) printf("%s",a)
#define cs printf("Case %d: ",kk++)
#define cn printf("Case %d:\n",kk++)
///#define c# printf("Case #%d: ",kk++)
#define Mid(l,r) (l+(r-l)>>1)
#define nl printf("\n")
#define done cout<<"done"<<endl;
#define eps 1e-9
#define mod 1000000007
#define inf INT_MAX
#define MX 100010
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define fast ios_base::sync_with_stdio(false);
int power(int x, unsigned int y)
{
int res = 1;
while (y > 0)
{
if (y & 1)
res = res*x;
y = y>>1;
x = x*x;
}
return res;
}
template<typename T>inline string tostring(T a)
{
ostringstream os("");
os << a;
return os.str();
}
template<typename T>inline ll tolong(T a)
{
ll res;
istringstream os(a);
os>>res;
return res;
}
template<typename T>inline vi parse(T str)
{
vi res;
int s;
istringstream os(str);
while(os>>s)res.pb(s);
return res;
}
ll SQRT(ll n)
{
ll e=sqrt(n*1.0);
ll l=max(0LL,e-2),r=min(n,e+2);
ll ans=0;
while(l<=r)
{
ll m=Mid(l,r);
if(m*m<=n)ans=m,l=m+1;
else r=m-1;
}
return ans;
}
ll CBRT(ll n)
{
ll e=cbrt(n*1.0);
ll l=max(0LL,e-2),r=min(n,e+2);
ll ans=0;
while(l<=r)
{
ll m=Mid(l,r);
if(m*m*m<=n)ans=m,l=m+1;
else r=m-1;
}
return ans;
}
template< class T > inline T _bigmod(T n,T m)
{
T ans=1,mult=n%mod;
while(m)
{
if(m & 1) ans=(ans*mult)%mod;
m>>=1;
mult=(mult*mult)%mod;
}
ans%=mod;
return ans;
}
template< class T > inline T _modinv(T x)
{
return _bigmod(x,(T) mod-2)%mod;
}
inline int len(string a)
{
return a.length();
}
inline int len(char a[])
{
return strlen(a);
}
template<class T> inline T _gcd(T a, T b)
{
return (b==0) ? a : _gcd(b, a % b);
}
template< class T > inline T _lcm(T x,T y)
{
return x*y/_gcd(x,y);
}
inline void fastIn(int &num) // Fast IO, with space and new line ignoring
{
bool neg = false;
register int c;
num = 0;
c = getchar();
for( ; c != '-' && (c < '0' || c > '9'); c = getchar());
if (c == '-')
{
neg = true;
c = getchar();
}
for(; (c>47 && c<58); c=getchar())
num = (num<<1) + (num<<3) + c - 48;
if(neg)
num *= -1;
}
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]= {1,1,0,-1,-1,-1,0,1};
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//int EQ(double d) {
// if ( fabs(d) < EPS ) return 0;
// return d > EPS ? 1 : -1 ;
//}
int main()
{
// clock_t begin = clock();
// //your code goes here
// //end here
// clock_t end = clock();
// double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
// cerr<<"Running Time: "<<time_spent<<" Seconds"<<endl;
return 0;
}