Coding Template C++
Coding Template C++
h>
using namespace std;
#define int long long
#define double long double
#define endl "\n"
#define pb push_back
#define PI 3.1415926535897932384626433832795l
#define F first
#define S second
#define mp make_pair
#define f(i,n) for(int i=0;i<n;i++)
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define gcd(a,b) __gcd((a),(b))
#define fill(a,value) memset(a,value,sizeof(a));
#define minn(v) *min_element(v.begin(), v.end());
#define maxx(v) *max_element(v.begin(), v.end());
#define print(x) cout<<(x)<<endl;
#define sum(v)+x accumulate(v.begin(), v.end(),x);
#define debug(x) cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int> pii;
typedef vector<int> vi;
/*
max and min value in a set
max_element = *(my_set.rbegin());
min_element = *my_set.begin();
*/
//x.substr(start, length);
/*
Create a vector containing n
vectors of size m.
---vector<vector<int> > vec( n , vector<int> (m, 0));
*/
struct type{
int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n)
{
if (n <= 1)
return false;
if (n <= 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
return true;
}
vector<int>factors(int n)
{
// Note that this loop runs till square root
vi ans;
for (int i=1; i<=sqrt(n); i++)
{
if (n%i == 0)
{
if (n == i*i )ans.pb(i);
else
{
ans.pb(i);
if (i!=n/i)ans.pb(n/i);
}
}
}
sort(all(ans));
return ans;
}
// Recursive C++ program to check if a string is subsequence of another string
bool isSubSequence(char str1[], char str2[], int m, int n)
{
// Base Cases
if (m == 0) return true;
if (n == 0) return false;
while (y > 0) {
// If y is odd, multiply x with result
if (y & 1)
res = (res * x) % p;
}
return 0;
}