diff --git a/Lecture_1/extended.cpp b/Lecture_1/extended.cpp new file mode 100644 index 0000000..c18b9fa --- /dev/null +++ b/Lecture_1/extended.cpp @@ -0,0 +1,14 @@ +ll x,y; +template T gcd(T a,T b) +{ + if(a==0) + { + x=0,y=1; return b; + } + T gc=gcd(b%a,a); + T temp; + temp=x; + x=y-(b/a)*temp; + y=temp; + return gcd; +} diff --git a/Lecture_1/functors b/Lecture_1/functors new file mode 100755 index 0000000..713f700 Binary files /dev/null and b/Lecture_1/functors differ diff --git a/Lecture_1/functors.cpp b/Lecture_1/functors.cpp new file mode 100644 index 0000000..b1d4677 --- /dev/null +++ b/Lecture_1/functors.cpp @@ -0,0 +1,151 @@ +#include +#include +#include + +using namespace __gnu_pbds; +using namespace std; + +#define pb push_back +#define f first +#define s second +#define mp make_pair +#define SZ(x) ((int)(x.size())) +#define FOI(i, a, n) for( i = int(a); i <= int(n); i++) +#define FOD(i, a, n) for( i = int(a); i >= int(n); i--) +#define IN(x, y) ((y).find(x) != (y).end()) +#define ALL(t) t.begin(),t.end() +#define MSET(tabl,i) memset(tabl, i, sizeof(tabl)) +#define PSET(x,y) fixed< + void __f(const char* names, Arg1&& arg1, Args&&... args){ + const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); + } +#else +#define trace(...) +#endif + +const int N = 1e5 + 5; +const int lgN = 1e6+5; +const int te = 3e8+1; +const ll MOD = 998244353; +const lf pi = 3.141592653589793238462643383; +const ll IMAX = 1e9 + 5; +const double PI = 3.141592653589793; + + +template +using max_pq = priority_queue; +template +using min_pq = priority_queue,greater>; +template +using OST = tree, rb_tree_tag, tree_order_statistics_node_update>; + +ll x,y; +template T gcd(T a,T b){ if(a==0) {x=0,y=1; return b;}T gc=gcd(b%a,a);T temp;temp=x;x=y-(b/a)*temp;y=temp;return gc;} + +//(a^x)%m +ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1; while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; } + +ll modInverse(ll A, ll M) +{ + gcd(A,M); + return (x%M+M)%M; //x may be negative +} + + + +#include +#include +#include +using namespace std; + +class Compare{ +public: + bool operator()(pair a,pair b){ + + + if(a.f maxHeap; + + priority_queue ,vector >,Compare> q; //Min Heap + + ll n,i; + cin>>n; + + vector > v(n); + FOI(i,0,n-1) + { + cin>>v[i].f; + cin>>v[i].s; + } + for(int i=0;i>n; + ll i,x; + priority_queue , functors > pq; + FOI(i,0,n-1) + { + cin>>x; + pq.push(x); + } + + while(!pq.empty()) + { + x=pq.top(); + pq.pop(); + cout< +#include +#include + +using namespace __gnu_pbds; +using namespace std; + +#define pb push_back +#define f first +#define s second +#define mp make_pair +#define SZ(x) ((int)(x.size())) +#define FOI(i, a, n) for( i = int(a); i <= int(n); i++) +#define FOD(i, a, n) for( i = int(a); i >= int(n); i--) +#define IN(x, y) ((y).find(x) != (y).end()) +#define ALL(t) t.begin(),t.end() +#define MSET(tabl,i) memset(tabl, i, sizeof(tabl)) +#define PSET(x,y) fixed< + void __f(const char* names, Arg1&& arg1, Args&&... args){ + const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); + } +#else +#define trace(...) +#endif + +const int N = 1e5 + 5; +const int lgN = 1e6+5; +const int te = 3e8+1; +const ll MOD = 998244353; +const lf pi = 3.141592653589793238462643383; +const ll IMAX = 1e9 + 5; +const double PI = 3.141592653589793; + + +template +using max_pq = priority_queue; +template +using min_pq = priority_queue,greater>; +template +using OST = tree, rb_tree_tag, tree_order_statistics_node_update>; + +ll x,y; +template T gcd(T a,T b){ if(a==0) {x=0,y=1; return b;}T gc=gcd(b%a,a);T temp;temp=x;x=y-(b/a)*temp;y=temp;return gc;} + +//(a^x)%m +ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1; while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; } + +ll modInverse(ll A, ll M) +{ + gcd(A,M); + return (x%M+M)%M; //x may be negative +} + + +// #include +int main() +{ + ll n,i; + cin>>n; + vector v(n); + FOI(i,0,n-1) + cin>>v[i]; + + ll x; + cin>>x; + if(binary_search(v.begin(),v.end(),x)) + { + cout<<"found\n"; + } + // lower_bound() + + vector::iterator it=upper_bound(v.begin(),v.end(),x); + int p=(it-v.begin()); + cout< +#include +#include + +using namespace __gnu_pbds; +using namespace std; + +#define pb push_back +#define f first +#define s second +#define mp make_pair +#define SZ(x) ((int)(x.size())) +#define FOI(i, a, n) for( i = int(a); i <= int(n); i++) +#define FOD(i, a, n) for( i = int(a); i >= int(n); i--) +#define IN(x, y) ((y).find(x) != (y).end()) +#define ALL(t) t.begin(),t.end() +#define MSET(tabl,i) memset(tabl, i, sizeof(tabl)) +#define PSET(x,y) fixed< + void __f(const char* names, Arg1&& arg1, Args&&... args){ + const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); + } +#else +#define trace(...) +#endif + +const int N = 1e5 + 5; +const int lgN = 1e6+5; +const int te = 3e8+1; +const ll MOD = 998244353; +const lf pi = 3.141592653589793238462643383; +const ll IMAX = 1e9 + 5; +const double PI = 3.141592653589793; + + +template +using max_pq = priority_queue; +template +using min_pq = priority_queue,greater>; +template +using OST = tree, rb_tree_tag, tree_order_statistics_node_update>; + +ll x,y; +template T gcd(T a,T b){ if(a==0) {x=0,y=1; return b;}T gc=gcd(b%a,a);T temp;temp=x;x=y-(b/a)*temp;y=temp;return gc;} + +//(a^x)%m +ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1; while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; } + +ll modInverse(ll A, ll M) +{ + gcd(A,M); + return (x%M+M)%M; //x may be negative +} + +//#include + +int main() +{ + map m; + m["abc"]=1; + m["sxn"]=45; + m["ksk"]=3; + + for(map::iterator it=m.begin();it!=m.end();it++) + { + cout<f<<" "<s<<"\n"; + } + string s; + cin>>s; + map::iterator it=m.find(s); + if(it!=m.end()) + cout<s; + else + { + cout<<"Not found\n"; + } + return 0; + +} + +// #include +/* + +SET +int main() +{ + ll n,i,x; + cin>>n; + set s; + FOI(i,0,n-1) + { + cin>>x; + s.insert(x); + } + + for(set::iterator it= s.begin();it!=s.end();it++) + { + cout<<(*it)<<"\n"; + } + + cin>>x; + if(s.find(x)!=s.end()) + { + cout<<"found\n"; + } + return 0; + +} + +*/ \ No newline at end of file diff --git a/Lecture_1/stl b/Lecture_1/stl new file mode 100755 index 0000000..e93467a Binary files /dev/null and b/Lecture_1/stl differ diff --git a/Lecture_1/stl.cpp b/Lecture_1/stl.cpp new file mode 100644 index 0000000..117ee69 --- /dev/null +++ b/Lecture_1/stl.cpp @@ -0,0 +1,123 @@ +#include +#include +#include + +using namespace __gnu_pbds; +using namespace std; + +#define pb push_back +#define f first +#define s second +#define mp make_pair +#define SZ(x) ((int)(x.size())) +#define FOI(i, a, n) for( i = int(a); i <= int(n); i++) +#define FOD(i, a, n) for( i = int(a); i >= int(n); i--) +#define IN(x, y) ((y).find(x) != (y).end()) +#define ALL(t) t.begin(),t.end() +#define MSET(tabl,i) memset(tabl, i, sizeof(tabl)) +#define PSET(x,y) fixed< + void __f(const char* names, Arg1&& arg1, Args&&... args){ + const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); + } +#else +#define trace(...) +#endif + +const int N = 1e5 + 5; +const int lgN = 1e6+5; +const int te = 3e8+1; +const ll MOD = 998244353; +const lf pi = 3.141592653589793238462643383; +const ll IMAX = 1e9 + 5; +const double PI = 3.141592653589793; + + +template +using max_pq = priority_queue; +template +using min_pq = priority_queue,greater>; +template +using OST = tree, rb_tree_tag, tree_order_statistics_node_update>; + +ll x,y; +template T gcd(T a,T b){ if(a==0) {x=0,y=1; return b;}T gc=gcd(b%a,a);T temp;temp=x;x=y-(b/a)*temp;y=temp;return gc;} + +//(a^x)%m +ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1; while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; } + +ll modInverse(ll A, ll M) +{ + gcd(A,M); + return (x%M+M)%M; //x may be negative +} + +bool mycompare(pair p1,pair p2) +{ + if(p1.f.length()p2.s) + return true; + } + return false; + + +} + +int main() +{ + + ll n,i; + /*char a[100]; + cin.getline(a,100); + cout<>n; + + vector >v(n); + FOI(i,0,n-1) + { + cin.get(); + cin>>v[i].f; + cin>>v[i].s; + //trace(v[i].f,v[i].s); + } + + sort(v.begin(),v.end(),mycompare); + FOI(i,0,n-1) + { + cout< +#include +using namespace std; + + +int main(){ + + char s[1000]; + cin.getline(s,1000); + + char *ptr = strtok(s," "); + + while(ptr!=NULL){ + cout< +#include +#include + +using namespace __gnu_pbds; +using namespace std; + +#define pb push_back +#define f first +#define s second +#define mp make_pair +#define SZ(x) ((int)(x.size())) +#define FOI(i, a, n) for( i = int(a); i <= int(n); i++) +#define FOD(i, a, n) for( i = int(a); i >= int(n); i--) +#define IN(x, y) ((y).find(x) != (y).end()) +#define ALL(t) t.begin(),t.end() +#define MSET(tabl,i) memset(tabl, i, sizeof(tabl)) +#define PSET(x,y) fixed< + void __f(const char* names, Arg1&& arg1, Args&&... args){ + const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); + } +#else +#define trace(...) +#endif + +const int N = 1e5 + 5; +const int lgN = 1e6+5; +const int te = 3e8+1; +const ll MOD = 998244353; +const lf pi = 3.141592653589793238462643383; +const ll IMAX = 1e9 + 5; +const double PI = 3.141592653589793; + + +template +using max_pq = priority_queue; +template +using min_pq = priority_queue,greater>; +template +using OST = tree, rb_tree_tag, tree_order_statistics_node_update>; + +ll x,y; +template T gcd(T a,T b){ if(a==0) {x=0,y=1; return b;}T gc=gcd(b%a,a);T temp;temp=x;x=y-(b/a)*temp;y=temp;return gc;} + +//(a^x)%m +ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1; while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; } + +ll modInverse(ll A, ll M) +{ + gcd(A,M); + return (x%M+M)%M; //x may be negative +} + +int main() +{ + ll n,i; + cin>>n; + vector v(n+1),s(n+1); + map > m; + m[0].pb(0); + FOI(i,1,n) + { + cin>>v[i]; + s[i]=s[i-1]+v[i]; + s[i]=s[i]%n; + m[s[i]].pb(i); + } + ll j; + FOI(i,0,n-1) + { + if(m.find(i)!=m.end()) + { + if(m[i].size()>=2) + FOI(j,0,m[i].size()-2) + { + ll x=m[i][j]+1; + ll y=m[i][j+1]; + cout< +#include +#include + +using namespace __gnu_pbds; +using namespace std; + +#define pb push_back +#define f first +#define s second +#define mp make_pair +#define SZ(x) ((int)(x.size())) +#define FOI(i, a, n) for( i = int(a); i <= int(n); i++) +#define FOD(i, a, n) for( i = int(a); i >= int(n); i--) +#define IN(x, y) ((y).find(x) != (y).end()) +#define ALL(t) t.begin(),t.end() +#define MSET(tabl,i) memset(tabl, i, sizeof(tabl)) +#define PSET(x,y) fixed< + void __f(const char* names, Arg1&& arg1, Args&&... args){ + const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); + } +#else +#define trace(...) +#endif + +const int N = 1e5 + 5; +const int lgN = 1e6+5; +const int te = 3e8+1; +const ll MOD = 998244353; +const lf pi = 3.141592653589793238462643383; +const ll IMAX = 1e9 + 5; +const double PI = 3.141592653589793; + + +template +using max_pq = priority_queue; +template +using min_pq = priority_queue,greater>; +template +using OST = tree, rb_tree_tag, tree_order_statistics_node_update>; + +ll x,y; +template T gcd(T a,T b){ if(a==0) {x=0,y=1; return b;}T gc=gcd(b%a,a);T temp;temp=x;x=y-(b/a)*temp;y=temp;return gc;} + +//(a^x)%m +ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1; while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; } + +ll modInverse(ll A, ll M) +{ + gcd(A,M); + return (x%M+M)%M; //x may be negative +} + +int main() +{ + ll n,i,N; + cin>>n; + cin>>N; + vector v(n); + FOI(i,0,n-1) + cin>>v[i]; + ll ans=0; + + FOI(i,1,(1<0) + { + temp=temp*v[l]; + g++; + } + l++; + j=j<<1; + } + cout<