diff --git a/.cph/.1348B_Phoenix_and_Beauty.cpp_cc77b8f26976a3fd6d56b532ff6b8e6c.prob b/.cph/.1348B_Phoenix_and_Beauty.cpp_cc77b8f26976a3fd6d56b532ff6b8e6c.prob new file mode 100644 index 0000000..2bd430c --- /dev/null +++ b/.cph/.1348B_Phoenix_and_Beauty.cpp_cc77b8f26976a3fd6d56b532ff6b8e6c.prob @@ -0,0 +1 @@ +{"name":"Local: 1348B_Phoenix_and_Beauty","url":"/Users/vidurgoel/Codeforces/1348B_Phoenix_and_Beauty.cpp","tests":[{"id":1681666529947,"input":"4\n4 2\n1 2 2 1\n4 3\n1 2 2 1\n3 2\n1 2 3\n4 4\n4 3 4 2\n","output":"8\n1 2 1 2 1 2 1 2 \n12\n1 2 3 1 2 3 1 2 3 1 2 3 \n-1\n16\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/vidurgoel/Codeforces/1348B_Phoenix_and_Beauty.cpp","group":"local","local":true} \ No newline at end of file diff --git a/.cph/.1360E_Polygon.cpp_7691f6e22bcd1f0e2480b1115e7ea501.prob b/.cph/.1360E_Polygon.cpp_7691f6e22bcd1f0e2480b1115e7ea501.prob new file mode 100644 index 0000000..55e738d --- /dev/null +++ b/.cph/.1360E_Polygon.cpp_7691f6e22bcd1f0e2480b1115e7ea501.prob @@ -0,0 +1 @@ +{"name":"Local: 1360E_Polygon","url":"/Users/vidurgoel/Codeforces/1360E_Polygon.cpp","tests":[{"id":1681711339539,"input":"5\n4\n0010\n0011\n0000\n0000\n2\n10\n01\n2\n00\n00\n4\n0101\n1111\n0101\n0111\n4\n0100\n1110\n0101\n0111","output":"YES\nNO\nYES\nYES\nNO"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/vidurgoel/Codeforces/1360E_Polygon.cpp","group":"local","local":true} \ No newline at end of file diff --git a/.cph/.515C_Drazil_and_Factorial.cpp_581344e6d22275df4a76354b75a9475d.prob b/.cph/.515C_Drazil_and_Factorial.cpp_581344e6d22275df4a76354b75a9475d.prob new file mode 100644 index 0000000..d8f97cb --- /dev/null +++ b/.cph/.515C_Drazil_and_Factorial.cpp_581344e6d22275df4a76354b75a9475d.prob @@ -0,0 +1 @@ +{"name":"Local: 515C_Drazil_and_Factorial","url":"/Users/vidurgoel/Codeforces/515C_Drazil_and_Factorial.cpp","tests":[{"id":1681714684464,"input":"4\n1234","output":"33222"},{"id":1681715074587,"input":"3\n555","output":"555"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/vidurgoel/Codeforces/515C_Drazil_and_Factorial.cpp","group":"local","local":true} \ No newline at end of file diff --git a/1348B_Phoenix_and_Beauty.bin b/1348B_Phoenix_and_Beauty.bin new file mode 100755 index 0000000..a5db880 Binary files /dev/null and b/1348B_Phoenix_and_Beauty.bin differ diff --git a/1348B_Phoenix_and_Beauty.cpp b/1348B_Phoenix_and_Beauty.cpp new file mode 100644 index 0000000..fa5fa8c --- /dev/null +++ b/1348B_Phoenix_and_Beauty.cpp @@ -0,0 +1,334 @@ +// Vidur Goel + +//Codeforcees Handle: Vidurcodviz + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace chrono; + +void solve_array(); +void solve_single(); +void solve_mul(); + +typedef long long int ll; +typedef unsigned long long int ull; +typedef long double lld; +typedef vector vl; +typedef pair pll; +typedef vector vpll; +typedef vector vvl; + +#define make_it_fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); +#define rept(i, a, n) for (ll i = (a); i < (n); i++) +#define all(x) (x).begin(), (x).end() +#define sor(x) sort(all(x)) +#define sorr(x) sort(x.rbegin(),x.rend()) // this is in order to do sorting in descending order +#define lb lower_bound +#define ub upper_bound +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ff first +#define ss second +#define MOD 1000000007 +#define MOD1 998244353 +#define PI 3.141592653589793238462 +#define mset multiset // it contains multiple instances of the same value in ascending order +#define rep(i,a,b) for(ll i=a;i=a;i--) +#define nn endl +#define setbits(n) __builtin_popcount(n) + +vl seive(1000002,-1); + +string yup="YES"; +string nope="NO"; + +ll lmin(vl arr){return *min_element(arr.begin(),arr.end());} +ll lmax(vl arr){return *max_element(arr.begin(),arr.end());} + +ll fibonacci(ll n){ll a=0;ll b=1;ll c;if(n==0 || n==1){return n;}for(ll i=2;i>arr[i];}return;} +void prv(vl arr){rep(i,0,arr.size()){cout<1 that divides i actually + +vl segmented_seive(ll l,ll r){ + ll n=r; + ll num=(ll)ceil(sqrtl(n)); + vl is_prime(num,-1); + vl primes; + vl ans(r-l+1,-1); + for(ll i=2;i<=num;i++){ + if(is_prime[i]==-1){ + primes.pb(i); + for(ll j=i*i;j1 that divides l+i actually. + +void seiv(){ + seive[0]=0; + seive[1]=1; + rep(i,2,(ll)floor(sqrtl(1000002))+1){ + if(seive[i]==-1){ + seive[i]=-1; + for(ll j=i*i;j<1000002;j=j+i){ + if(seive[j]==-1){ + seive[j]=i; + } + } + } + } +} + +// Always return a positive integer +ll gcd(ll a,ll b){a=abs(a);b=abs(b);ll k=1;while(a%2==0 && b%2==0){k=2*k;a=a/2;b=b/2;}while(a%2==0){a=a/2;}while(b%2==0){b=b/2;}while(b!=0){a=a%b;swap(a,b);}return k*a;} + +// This implementation of extended Euclidean algorithm produces correct results for negative integers as well. +ll gcd(ll a,ll b,ll &x,ll &y){if(b == 0){x = 1;y = 0;return a;}ll x1, y1;ll d = gcd(b, a % b, x1, y1);x = y1;y = x1 - y1 * (a / b);return d;} + +// Always return a positive integer +ll lcm(ll a,ll b){a=abs(a);b=abs(b);return (a/gcd(a, b))*b;} + +// Binary Exponentiation +ll binpow(ll a,ll n){ll res=1;while(n!=0){if(n%2==0){a=a*a;n=n/2;}else{res=res*a;n=n-1;}}return res;} + +// Modulo Binary Exponentiation +ll binpowmod(ll a,ll n,ll m){ll res=1;while(n!=0){if(n%2==0){a=a*a%m;n=n/2;}else{res=res*a%m;n=n-1;}}return res;} + +// if we know that in Modulo Binary Exponentiation the m is going to be prime than even for n>>m we can speed it up +ll binpowmod_prime(ll a,ll n,ll m){ll res=1;while(n!=0){if(n%2==0){a=a*a%m;n=(n/2)%(m-1);}else{res=res*a%m;n=(n-1)%(m-1);}}return res;} + +ll add_mod(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;} +ll mul_mod(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;} +ll sub_mod(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;} + +/* + A) double sqrt(double arg): It returns the square root of a number to type double. + B) float sqrtf(float arg): It returns the square root of a number to type float. + C) long double sqrtl(long double arg): It returns the square root of a number to type long double with more precision. + Advised to always use C) as always give correct one as other may halt in case of the big numbers + cbrt() in built function to give the cube root in float/double + abs() is used for the absolute value of a number + swap() function in c++ used to swap value of two elements of the same data type. + toupper() This function is used for converting a lowercase character to uppercase. + tolower() This function is used for converting an uppercase character to lowercase. + ceil() and floor() function + sort(vect.begin(),vect.end(), greater()); + reverse(vect.begin(), vect.end()); + count(first_iterator, last_iterator,x) – To count the occurrences of x in vector. + find(first_iterator, last_iterator, x) – Returns an iterator to the first occurrence of x in vector and points to last address of vector ((name_of_vector).end()) if element is not present in vector + + maximium value long long can take 9, 223, 372, 036, 854, 775, 807 + 2^63-1 + i.e, length of 19 only + maximium value long long can take 18, 446, 744, 073, 709, 551, 615 + 2^64-1 + i.e, length of 20 only + + lower_bound(v.begin(), v.end(), 6) these are the syntax + upper_bound(v.begin(), v.end(), 6) + + In multiset to remove all element of a same number use a.erase() + else to remove 1 lement only use ans.erase(ans.find(*it)) here it is the iterator + + priority_queue, greater > gquiz(arr, arr + n); + Here above is the syntax of the min_heap implementation with the help of the priority queue and here push() and pop() and top() are the main operations + priority_queue gquiz(arr, arr + n); + Here above is the syntax of the max_heap implementation with the help of the priority queue and here push() and pop() and top() are the main operations + + Whenever need to do the hashing always use the map which is the stl template of hashing never use the array indexing method. + map.find() function has complexity 0(logn) + map.insert function has complexity 0(1) + __builtin_popcount(n) - we use this function to count the number of 1's (set bits) in the number in binary form + __builtin_parity(n) - this is boolean function which return true if number of 1's in binary form of n are odd else returns false; + __builtin_clz(n) - eg: Binary form of 16 is 00000000 00000000 00000000 00010000 therefore will return the number of the leading zeroes in n here answer will be 27 + __builtin_ctz(n) - eg: Binary form of 20 is 00000000 00000000 00000000 00010100 therefore will return the number of the trailing zeroes in n here answer will be 2 + + An important info about the lower_bound used in various data structures + actually if number is present they will return te iterator pointing to that number in the data structure otherwise return the + next iterator in that data structure so depends whether sorted in ascending or descending order. + An important info about the upper_bound used in various data structures + is that it will return the iterator pointing to the next iterator to which the number should be there also depends on the sorting order + + Modulo operations, although we see them as O(1), are a lot slower than simpler operations like addition, subtraction or bitwise operations. So it would be better to avoid those. + + Always in the question related to the graph always access from the global variables +*/ + +struct dsu{ + vl parent; + vl size; + + dsu(ll n){ + size.resize(n+1); + parent.resize(n+1); + rep(i,0,n+1){ + make_set(i); + } + } + + void make_set(ll v){ + parent[v]=v; + size[v]=1; + } + + ll find_set(ll v){ + if(v==parent[v]){ + return v; + } + else{ + return parent[v]=find_set(parent[v]); + } + } + void union_set(ll a,ll b){ + a=find_set(a); + b=find_set(b); + if(a==b){ + return; + } + else{ + if(size[a]>=size[b]){ + parent[b]=a; + size[a] += size[b]; + } + else{ + parent[a]=b; + size[b] += size[a]; + } + } + } +}; + +bool mycompare(pll p1 ,pll p2){ + if(p1.first>test; + rep(i,0,test){ + solve_array(); + } +} + +void solve_single(){ + ll n; + cin>>n; +} + +void solve_array(){ + ll n,k; + cin>>n>>k; + vl arr(n,0); + rev(arr,n); + set st; + map mpt; + rep(i,0,n){ + st.insert(arr[i]); + mpt[arr[i]]=1; + } + if(mpt.size()>k){ + cout<<-1< :: iterator it; + it=st.begin(); + rep(i,0,n){ + while(it!=st.end()){ + cout<<*it<<" "; + it++; + } + it=st.begin(); + } + cout<>n>>m; + vl a; + vvl arr(n,a); + rep(i,0,m){ + ll x,y; + cin>>x>>y; + arr[x-1].pb(y); + arr[y-1].pb(x); + } +} + +signed main(){ + make_it_fast(); + //seive(); + solve_mul(); + //solve_array(); + //solve_single(); + //solve_graph(); + return 0; +} \ No newline at end of file diff --git a/1360E_Polygon.bin b/1360E_Polygon.bin new file mode 100755 index 0000000..67a808a Binary files /dev/null and b/1360E_Polygon.bin differ diff --git a/1360E_Polygon.cpp b/1360E_Polygon.cpp new file mode 100644 index 0000000..abde81a --- /dev/null +++ b/1360E_Polygon.cpp @@ -0,0 +1,330 @@ +// Vidur Goel + +//Codeforcees Handle: Vidurcodviz + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace chrono; + +void solve_array(); +void solve_single(); +void solve_mul(); + +typedef long long int ll; +typedef unsigned long long int ull; +typedef long double lld; +typedef vector vl; +typedef pair pll; +typedef vector vpll; +typedef vector vvl; + +#define make_it_fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); +#define rept(i, a, n) for (ll i = (a); i < (n); i++) +#define all(x) (x).begin(), (x).end() +#define sor(x) sort(all(x)) +#define sorr(x) sort(x.rbegin(),x.rend()) // this is in order to do sorting in descending order +#define lb lower_bound +#define ub upper_bound +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ff first +#define ss second +#define MOD 1000000007 +#define MOD1 998244353 +#define PI 3.141592653589793238462 +#define mset multiset // it contains multiple instances of the same value in ascending order +#define rep(i,a,b) for(ll i=a;i=a;i--) +#define nn endl +#define setbits(n) __builtin_popcount(n) + +vl seive(1000002,-1); + +string yup="YES"; +string nope="NO"; + +ll lmin(vl arr){return *min_element(arr.begin(),arr.end());} +ll lmax(vl arr){return *max_element(arr.begin(),arr.end());} + +ll fibonacci(ll n){ll a=0;ll b=1;ll c;if(n==0 || n==1){return n;}for(ll i=2;i>arr[i];}return;} +void prv(vl arr){rep(i,0,arr.size()){cout<1 that divides i actually + +vl segmented_seive(ll l,ll r){ + ll n=r; + ll num=(ll)ceil(sqrtl(n)); + vl is_prime(num,-1); + vl primes; + vl ans(r-l+1,-1); + for(ll i=2;i<=num;i++){ + if(is_prime[i]==-1){ + primes.pb(i); + for(ll j=i*i;j1 that divides l+i actually. + +void seiv(){ + seive[0]=0; + seive[1]=1; + rep(i,2,(ll)floor(sqrtl(1000002))+1){ + if(seive[i]==-1){ + seive[i]=-1; + for(ll j=i*i;j<1000002;j=j+i){ + if(seive[j]==-1){ + seive[j]=i; + } + } + } + } +} + +// Always return a positive integer +ll gcd(ll a,ll b){a=abs(a);b=abs(b);ll k=1;while(a%2==0 && b%2==0){k=2*k;a=a/2;b=b/2;}while(a%2==0){a=a/2;}while(b%2==0){b=b/2;}while(b!=0){a=a%b;swap(a,b);}return k*a;} + +// This implementation of extended Euclidean algorithm produces correct results for negative integers as well. +ll gcd(ll a,ll b,ll &x,ll &y){if(b == 0){x = 1;y = 0;return a;}ll x1, y1;ll d = gcd(b, a % b, x1, y1);x = y1;y = x1 - y1 * (a / b);return d;} + +// Always return a positive integer +ll lcm(ll a,ll b){a=abs(a);b=abs(b);return (a/gcd(a, b))*b;} + +// Binary Exponentiation +ll binpow(ll a,ll n){ll res=1;while(n!=0){if(n%2==0){a=a*a;n=n/2;}else{res=res*a;n=n-1;}}return res;} + +// Modulo Binary Exponentiation +ll binpowmod(ll a,ll n,ll m){ll res=1;while(n!=0){if(n%2==0){a=a*a%m;n=n/2;}else{res=res*a%m;n=n-1;}}return res;} + +// if we know that in Modulo Binary Exponentiation the m is going to be prime than even for n>>m we can speed it up +ll binpowmod_prime(ll a,ll n,ll m){ll res=1;while(n!=0){if(n%2==0){a=a*a%m;n=(n/2)%(m-1);}else{res=res*a%m;n=(n-1)%(m-1);}}return res;} + +ll add_mod(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;} +ll mul_mod(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;} +ll sub_mod(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;} + +/* + A) double sqrt(double arg): It returns the square root of a number to type double. + B) float sqrtf(float arg): It returns the square root of a number to type float. + C) long double sqrtl(long double arg): It returns the square root of a number to type long double with more precision. + Advised to always use C) as always give correct one as other may halt in case of the big numbers + cbrt() in built function to give the cube root in float/double + abs() is used for the absolute value of a number + swap() function in c++ used to swap value of two elements of the same data type. + toupper() This function is used for converting a lowercase character to uppercase. + tolower() This function is used for converting an uppercase character to lowercase. + ceil() and floor() function + sort(vect.begin(),vect.end(), greater()); + reverse(vect.begin(), vect.end()); + count(first_iterator, last_iterator,x) – To count the occurrences of x in vector. + find(first_iterator, last_iterator, x) – Returns an iterator to the first occurrence of x in vector and points to last address of vector ((name_of_vector).end()) if element is not present in vector + + maximium value long long can take 9, 223, 372, 036, 854, 775, 807 + 2^63-1 + i.e, length of 19 only + maximium value long long can take 18, 446, 744, 073, 709, 551, 615 + 2^64-1 + i.e, length of 20 only + + lower_bound(v.begin(), v.end(), 6) these are the syntax + upper_bound(v.begin(), v.end(), 6) + + In multiset to remove all element of a same number use a.erase() + else to remove 1 lement only use ans.erase(ans.find(*it)) here it is the iterator + + priority_queue, greater > gquiz(arr, arr + n); + Here above is the syntax of the min_heap implementation with the help of the priority queue and here push() and pop() and top() are the main operations + priority_queue gquiz(arr, arr + n); + Here above is the syntax of the max_heap implementation with the help of the priority queue and here push() and pop() and top() are the main operations + + Whenever need to do the hashing always use the map which is the stl template of hashing never use the array indexing method. + map.find() function has complexity 0(logn) + map.insert function has complexity 0(1) + __builtin_popcount(n) - we use this function to count the number of 1's (set bits) in the number in binary form + __builtin_parity(n) - this is boolean function which return true if number of 1's in binary form of n are odd else returns false; + __builtin_clz(n) - eg: Binary form of 16 is 00000000 00000000 00000000 00010000 therefore will return the number of the leading zeroes in n here answer will be 27 + __builtin_ctz(n) - eg: Binary form of 20 is 00000000 00000000 00000000 00010100 therefore will return the number of the trailing zeroes in n here answer will be 2 + + An important info about the lower_bound used in various data structures + actually if number is present they will return te iterator pointing to that number in the data structure otherwise return the + next iterator in that data structure so depends whether sorted in ascending or descending order. + An important info about the upper_bound used in various data structures + is that it will return the iterator pointing to the next iterator to which the number should be there also depends on the sorting order + + Modulo operations, although we see them as O(1), are a lot slower than simpler operations like addition, subtraction or bitwise operations. So it would be better to avoid those. + + Always in the question related to the graph always access from the global variables +*/ + +struct dsu{ + vl parent; + vl size; + + dsu(ll n){ + size.resize(n+1); + parent.resize(n+1); + rep(i,0,n+1){ + make_set(i); + } + } + + void make_set(ll v){ + parent[v]=v; + size[v]=1; + } + + ll find_set(ll v){ + if(v==parent[v]){ + return v; + } + else{ + return parent[v]=find_set(parent[v]); + } + } + void union_set(ll a,ll b){ + a=find_set(a); + b=find_set(b); + if(a==b){ + return; + } + else{ + if(size[a]>=size[b]){ + parent[b]=a; + size[a] += size[b]; + } + else{ + parent[a]=b; + size[b] += size[a]; + } + } + } +}; + +bool mycompare(pll p1 ,pll p2){ + if(p1.first>test; + rep(i,0,test){ + solve_single(); + } +} + +void solve_single(){ + ll n; + cin>>n; + vector arr(n); + rep(i,0,n){ + cin>>arr[i]; + } + if(n==1){ + cout<>n; + vl arr(n,0); + rev(arr,n); +} + +void solve_graph(){ + ll n,m; + cin>>n>>m; + vl a; + vvl arr(n,a); + rep(i,0,m){ + ll x,y; + cin>>x>>y; + arr[x-1].pb(y); + arr[y-1].pb(x); + } +} + +signed main(){ + make_it_fast(); + //seive(); + solve_mul(); + //solve_array(); + //solve_single(); + //solve_graph(); + return 0; +} \ No newline at end of file diff --git a/515C_Drazil_and_Factorial.bin b/515C_Drazil_and_Factorial.bin new file mode 100755 index 0000000..1d04d88 Binary files /dev/null and b/515C_Drazil_and_Factorial.bin differ diff --git a/515C_Drazil_and_Factorial.cpp b/515C_Drazil_and_Factorial.cpp new file mode 100644 index 0000000..c42d233 --- /dev/null +++ b/515C_Drazil_and_Factorial.cpp @@ -0,0 +1,362 @@ +// Vidur Goel + +//Codeforcees Handle: Vidurcodviz + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace chrono; + +void solve_array(); +void solve_single(); +void solve_mul(); + +typedef long long int ll; +typedef unsigned long long int ull; +typedef long double lld; +typedef vector vl; +typedef pair pll; +typedef vector vpll; +typedef vector vvl; + +#define make_it_fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); +#define rept(i, a, n) for (ll i = (a); i < (n); i++) +#define all(x) (x).begin(), (x).end() +#define sor(x) sort(all(x)) +#define sorr(x) sort(x.rbegin(),x.rend()) // this is in order to do sorting in descending order +#define lb lower_bound +#define ub upper_bound +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ff first +#define ss second +#define MOD 1000000007 +#define MOD1 998244353 +#define PI 3.141592653589793238462 +#define mset multiset // it contains multiple instances of the same value in ascending order +#define rep(i,a,b) for(ll i=a;i=a;i--) +#define nn endl +#define setbits(n) __builtin_popcount(n) + +vl seive(1000002,-1); + +string yup="YES"; +string nope="NO"; + +ll lmin(vl arr){return *min_element(arr.begin(),arr.end());} +ll lmax(vl arr){return *max_element(arr.begin(),arr.end());} + +ll fibonacci(ll n){ll a=0;ll b=1;ll c;if(n==0 || n==1){return n;}for(ll i=2;i>arr[i];}return;} +void prv(vl arr){rep(i,0,arr.size()){cout<1 that divides i actually + +vl segmented_seive(ll l,ll r){ + ll n=r; + ll num=(ll)ceil(sqrtl(n)); + vl is_prime(num,-1); + vl primes; + vl ans(r-l+1,-1); + for(ll i=2;i<=num;i++){ + if(is_prime[i]==-1){ + primes.pb(i); + for(ll j=i*i;j1 that divides l+i actually. + +void seiv(){ + seive[0]=0; + seive[1]=1; + rep(i,2,(ll)floor(sqrtl(1000002))+1){ + if(seive[i]==-1){ + seive[i]=-1; + for(ll j=i*i;j<1000002;j=j+i){ + if(seive[j]==-1){ + seive[j]=i; + } + } + } + } +} + +// Always return a positive integer +ll gcd(ll a,ll b){a=abs(a);b=abs(b);ll k=1;while(a%2==0 && b%2==0){k=2*k;a=a/2;b=b/2;}while(a%2==0){a=a/2;}while(b%2==0){b=b/2;}while(b!=0){a=a%b;swap(a,b);}return k*a;} + +// This implementation of extended Euclidean algorithm produces correct results for negative integers as well. +ll gcd(ll a,ll b,ll &x,ll &y){if(b == 0){x = 1;y = 0;return a;}ll x1, y1;ll d = gcd(b, a % b, x1, y1);x = y1;y = x1 - y1 * (a / b);return d;} + +// Always return a positive integer +ll lcm(ll a,ll b){a=abs(a);b=abs(b);return (a/gcd(a, b))*b;} + +// Binary Exponentiation +ll binpow(ll a,ll n){ll res=1;while(n!=0){if(n%2==0){a=a*a;n=n/2;}else{res=res*a;n=n-1;}}return res;} + +// Modulo Binary Exponentiation +ll binpowmod(ll a,ll n,ll m){ll res=1;while(n!=0){if(n%2==0){a=a*a%m;n=n/2;}else{res=res*a%m;n=n-1;}}return res;} + +// if we know that in Modulo Binary Exponentiation the m is going to be prime than even for n>>m we can speed it up +ll binpowmod_prime(ll a,ll n,ll m){ll res=1;while(n!=0){if(n%2==0){a=a*a%m;n=(n/2)%(m-1);}else{res=res*a%m;n=(n-1)%(m-1);}}return res;} + +ll add_mod(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;} +ll mul_mod(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;} +ll sub_mod(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;} + +/* + A) double sqrt(double arg): It returns the square root of a number to type double. + B) float sqrtf(float arg): It returns the square root of a number to type float. + C) long double sqrtl(long double arg): It returns the square root of a number to type long double with more precision. + Advised to always use C) as always give correct one as other may halt in case of the big numbers + cbrt() in built function to give the cube root in float/double + abs() is used for the absolute value of a number + swap() function in c++ used to swap value of two elements of the same data type. + toupper() This function is used for converting a lowercase character to uppercase. + tolower() This function is used for converting an uppercase character to lowercase. + ceil() and floor() function + sort(vect.begin(),vect.end(), greater()); + reverse(vect.begin(), vect.end()); + count(first_iterator, last_iterator,x) – To count the occurrences of x in vector. + find(first_iterator, last_iterator, x) – Returns an iterator to the first occurrence of x in vector and points to last address of vector ((name_of_vector).end()) if element is not present in vector + + maximium value long long can take 9, 223, 372, 036, 854, 775, 807 + 2^63-1 + i.e, length of 19 only + maximium value long long can take 18, 446, 744, 073, 709, 551, 615 + 2^64-1 + i.e, length of 20 only + + lower_bound(v.begin(), v.end(), 6) these are the syntax + upper_bound(v.begin(), v.end(), 6) + + In multiset to remove all element of a same number use a.erase() + else to remove 1 lement only use ans.erase(ans.find(*it)) here it is the iterator + + priority_queue, greater > gquiz(arr, arr + n); + Here above is the syntax of the min_heap implementation with the help of the priority queue and here push() and pop() and top() are the main operations + priority_queue gquiz(arr, arr + n); + Here above is the syntax of the max_heap implementation with the help of the priority queue and here push() and pop() and top() are the main operations + + Whenever need to do the hashing always use the map which is the stl template of hashing never use the array indexing method. + map.find() function has complexity 0(logn) + map.insert function has complexity 0(1) + __builtin_popcount(n) - we use this function to count the number of 1's (set bits) in the number in binary form + __builtin_parity(n) - this is boolean function which return true if number of 1's in binary form of n are odd else returns false; + __builtin_clz(n) - eg: Binary form of 16 is 00000000 00000000 00000000 00010000 therefore will return the number of the leading zeroes in n here answer will be 27 + __builtin_ctz(n) - eg: Binary form of 20 is 00000000 00000000 00000000 00010100 therefore will return the number of the trailing zeroes in n here answer will be 2 + + An important info about the lower_bound used in various data structures + actually if number is present they will return te iterator pointing to that number in the data structure otherwise return the + next iterator in that data structure so depends whether sorted in ascending or descending order. + An important info about the upper_bound used in various data structures + is that it will return the iterator pointing to the next iterator to which the number should be there also depends on the sorting order + + Modulo operations, although we see them as O(1), are a lot slower than simpler operations like addition, subtraction or bitwise operations. So it would be better to avoid those. + + Always in the question related to the graph always access from the global variables +*/ + +struct dsu{ + vl parent; + vl size; + + dsu(ll n){ + size.resize(n+1); + parent.resize(n+1); + rep(i,0,n+1){ + make_set(i); + } + } + + void make_set(ll v){ + parent[v]=v; + size[v]=1; + } + + ll find_set(ll v){ + if(v==parent[v]){ + return v; + } + else{ + return parent[v]=find_set(parent[v]); + } + } + void union_set(ll a,ll b){ + a=find_set(a); + b=find_set(b); + if(a==b){ + return; + } + else{ + if(size[a]>=size[b]){ + parent[b]=a; + size[a] += size[b]; + } + else{ + parent[a]=b; + size[b] += size[a]; + } + } + } +}; + +bool mycompare(pll p1 ,pll p2){ + if(p1.first>test; + rep(i,0,test){ + + } +} + +void solve_single(){ + ll n; + cin>>n; + string s; + cin>>s; + map mpt; + rep(i,0,n){ + ll k=(ll)s[i]-'0'; + if(k==0 || k==1){ + continue; + } + else{ + while(k!=1){ + ll num=k; + rep(i,2,8){ + while(num%i==0){ + mpt[i]++; + num=num/i; + } + } + k--; + } + } + } + vl answer; + if(mpt[7]!=0){ + while(mpt[7]!=0){ + answer.pb(7); + mpt[7]--; + mpt[2]-=4; + mpt[3]-=2; + mpt[5]--; + } + } + if(mpt[5]!=0){ + while(mpt[5]!=0){ + answer.pb(5); + mpt[2]-=3; + mpt[3]-=1; + mpt[5]--; + } + } + if(mpt[3]!=0){ + while(mpt[3]!=0){ + answer.pb(3); + mpt[2]-=1; + mpt[3]-=1; + } + } + if(mpt[2]!=0){ + while(mpt[2]!=0){ + answer.pb(2); + mpt[2]--; + } + } + sor(answer); + rep(i,0,answer.size()){ + cout<>n; + vl arr(n,0); + rev(arr,n); +} + +void solve_graph(){ + ll n,m; + cin>>n>>m; + vl a; + vvl arr(n,a); + rep(i,0,m){ + ll x,y; + cin>>x>>y; + arr[x-1].pb(y); + arr[y-1].pb(x); + } +} + +signed main(){ + make_it_fast(); + //seive(); + //solve_mul(); + //solve_array(); + solve_single(); + //solve_graph(); + return 0; +} \ No newline at end of file