output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { ios::sync_with_stdio(0); int n; cin >> n; string str[n + 1]; string an; char ch; for (int i = 0; i < an.size(); i++) { if (an[i] == '?') { an[i] = '#'; } } for (int i = 0; i < n; i++) { cin >> str[i]; }...
### Prompt Create a solution in CPP for the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets...
#include <bits/stdc++.h> using namespace std; const int INF = int(1e9); const long long LINF = (long long)(5e18); template <class T> T nextInt() { T x = 0, p = 1; char c; do { c = getchar(); } while (c <= 32); if (c == '-') { p = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * ...
### Prompt Your task is to create a cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular ...
#include <bits/stdc++.h> using namespace std; vector<string> a; bool b[26]; vector<char> c; int main() { ios_base::sync_with_stdio(0); int t; cin >> t; a.resize(t); for (int i = 0; i < t; i++) { cin >> a[i]; } int m = a[0].size(); c.resize(m); for (int i = 0; i < m; i++) { memset(b, 0, sizeof(...
### Prompt Your challenge is to write a cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> n; for (int i = 0; i < n; i++) { string x; cin >> x; if (i == 0) { for (int j = 0; j < x.size(); j++) s += '-'; } for (int j = 0; j < x.size(); j++) { if (x[j] == '?') continue; if (s[j] == '...
### Prompt Please formulate a Cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 * 1000 + 5; string s[MAXN]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> s[i]; string ans = ""; for (int j = 0; j < (int)s[0].length(); j++) { bool b = false, b2 = false; char ch = '?'; for (int i = 0; i < n; i+...
### Prompt Construct a cpp code solution to the problem outlined: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string me...
#include <bits/stdc++.h> const int imax = INT32_MAX; const int imin = INT32_MIN; using namespace std; const long long int MOD = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long int t = 1; while (t--) { int n; cin >> n; string s[n]; for (int i = ...
### Prompt Create a solution in cpp for the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets...
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; char s[maxn]; char ans[maxn]; bool fix[maxn]; int main() { int n; scanf("%d", &n); memset(ans, '?', sizeof(ans)); memset(fix, false, sizeof(fix)); int len; for (int i = 0; i < n; ++i) { scanf("%s", s); len = strlen(s); f...
### Prompt Your task is to create a cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular ...
#include <bits/stdc++.h> const int N = 100050; int f[N][27]; int main() { int n; scanf("%d", &n); int m = 0; while (n--) { char c = getchar(); for (; (c < 'a' || c > 'z') && c != '?'; c = getchar()) ; int i = 1; for (; (c >= 'a' && c <= 'z') || c == '?'; c = getchar(), i++) { if (c =...
### Prompt Create a solution in CPP for the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets...
#include <bits/stdc++.h> const int MAX_LEN = 100005; using namespace std; char ans[MAX_LEN]; int main() { ios::sync_with_stdio(false); int stringc, length; cin >> stringc; for (int i = 0; i < stringc; i++) { string cur; cin >> cur; length = cur.size(); for (int j = 0; j < (int)cur.size(); j++) {...
### Prompt Create a solution in cpp for the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets...
#include <bits/stdc++.h> using namespace std; set<char> S; int main() { int n; scanf("%d", &n); string s; vector<string> a; int i, j, m; for (i = 0; i < n; i++) { cin >> s; m = s.size(); a.push_back(s); } string ans = ""; for (j = 0; j < m; j++) { S.clear(); int d = 0; char c =...
### Prompt Your challenge is to write a cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; char letter[26]; int judge[maxn]; int main() { int n; char str[maxn]; letter[0] = 'a'; for (int i = 1; i < 26; i++) letter[i] = letter[i - 1] + 1; while (~scanf("%d", &n)) { int flag = 0, len; memset(judge, 0, sizeof(judge)); ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; char s[100005], final[100005]; int main(void) { int n, len, i, j; while (scanf("%d", &n) != EOF) { scanf("%s", final); len = strlen(final); for (i = 2; i <= n; i++) { scanf("%s", s); for (j = 0; j < len; j++) { if (final[j] == '!') { ...
### Prompt Your task is to create a CPP solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular ...
#include <bits/stdc++.h> using namespace std; int main() { long long n; string s, ingresada; cin >> n >> s; long long size = s.size(); char string_final[size + 1]; if (n == 1) { for (int i = 0; i < size; i++) { if (s[i] == '?') { s[i] = 'a'; } } cout << s << endl; } else { ...
### Prompt Develop a solution in Cpp to the problem described below: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string...
#include <bits/stdc++.h> using namespace std; int main() { char a[1000000], b[1000000]; int n; cin >> n >> a; int l = strlen(a); for (int i = 1; i < n; i++) { cin >> b; for (int j = 0; j < l; j++) { if (a[j] == '?') a[j] = b[j]; else if (b[j] == '?') continue; else if...
### Prompt Your challenge is to write a Cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; int main() { char s[100005]; char p[100005]; int i, j, n, l; scanf("%d", &n); for (i = 0; i < n; i++) s[i] = 0; scanf("%s", p); l = strlen(p); for (i = 0; i < l; i++) s[i] = 0; for (i = 0; i < n; i++) { for (j = 0; j < l; j++) { if (p[j] != '?') ...
### Prompt Generate a CPP solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets t...
#include <bits/stdc++.h> using namespace std; int F[26]; int main() { int n; while (cin >> n) { string s; vector<string> V; for (int i = 0; i < n; i++) cin >> s, V.push_back(s); string ans; for (int j = 0; j < V[0].size(); j++) { memset(F, 0, sizeof F); for (int i = 0; i < n; i++) { ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; const int N = 1234567; char ans[N], foo[N]; int main() { int n; scanf("%d", &n); memset(ans, '*', sizeof(ans)); int len; for (int i = 0; i < n; i++) { scanf("%s", foo); len = strlen(foo); for (int j = 0; foo[j]; j++) if (foo[j] != '?') { ...
### Prompt Create a solution in Cpp for the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int sz = s.size(); char c; for (int i = 1; i < n; ++i) { for (int j = 0; j < sz; ++j) { cin >> c; if (c == '?') continue; if (s[j] == '?') s[j] = c; else if (s[j] != c) ...
### Prompt Please create a solution in CPP to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; string s, ans; int n, m; vector<char> st[maxn]; int main() { cin.tie(0), ios_base ::sync_with_stdio(0); cin >> n; for (int i = 0; i < n; i++) { cin >> s; m = s.size(); for (int j = 0; j < m; j++) st[j].push_back(s[j]); } ans...
### Prompt Your task is to create a Cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular ...
#include <bits/stdc++.h> const int maxn = 100100; char ch[maxn], ans[maxn]; int next[maxn]; int main() { int n, len; scanf("%d", &n); for (int i = 0; i < maxn; i++) { next[i] = i + 1; ans[i] = -1; } int f = 1; next[maxn - 1] = 0; while (n--) { scanf("%s", ch); if (f == 1) { f++; ...
### Prompt Generate a cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets t...
#include <bits/stdc++.h> using namespace std; int main() { string a, b; int n; cin >> n >> a; for (int j = 1; j < n; j++) { cin >> b; for (int i = 0; i < a.size(); i++) { if (a[i] == '?') { a[i] = b[i]; } if (a[i] == '.') { continue; } else { if (a[i] != b...
### Prompt Your challenge is to write a CPP solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string a[n + 1]; for (long long i = 0; i < n; i++) cin >> a[i]; long long len = a[0].size(); string res = ""; for (long long i = 0; i < len; i++) { map<char, long long> mp; for (long long j = 0; j < n; j++) { m...
### Prompt In CPP, your task is to solve the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meet...
#include <bits/stdc++.h> using namespace std; int n; int k = 0, t, q = 0; string s[100010]; char ch, zx; set<char> myset; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) cin >> s[i]; t = (int)s[1].size(); for (int j = 0; j < t; j++) { for (int i = 1; ...
### Prompt Your task is to create a Cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular ...
#include <bits/stdc++.h> using namespace std; const int N = 200000; int n, len; char ans[N], foo[N]; int main() { scanf("%d", &n); memset(ans, '*', sizeof ans); for (int i = 0; i < n; i++) { scanf("%s", foo); len = strlen(foo); for (int j = 0; j < len; j++) { if (foo[j] != '?') { if (ans...
### Prompt In CPP, your task is to solve the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meet...
#include <bits/stdc++.h> using namespace std; char a[100041]; int b[100041]; int c[100041]; string s; int main() { int n; cin >> n; int len; for (long long i = 0; i < 100003; i++) a[i] = '?', c[i] = 1; for (long long l = 0; l < n; l++) { cin >> s; len = s.size(); for (long long i = 0; i < s.size()...
### Prompt Construct a CPP code solution to the problem outlined: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string me...
#include <bits/stdc++.h> using namespace std; long n; char s[100100]; map<char, bool> mymap[100100]; void input() { long i, j, len, sz; scanf("%ld", &n); for (i = 0; i < n; i++) { scanf("%s", &s); for (j = 0; s[j]; j++) if (s[j] != '?') mymap[j][s[j]] = true; } for (i = 0; s[i]; i++) { sz = ...
### Prompt Create a solution in cpp for the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:33554432") using namespace std; int n; int bad[1 << 17]; char res[1 << 17]; char buf[1 << 17]; int main() { memset(bad, 0, sizeof(bad)); scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%s", buf); if (i == 0) memcpy(res, buf, sizeof(res))...
### Prompt In CPP, your task is to solve the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meet...
#include <bits/stdc++.h> const int M = 1e5 + 10; char str[M], c, n[M]; int m; int main() { scanf("%d", &m); getchar(); memset(n, 0, sizeof(n)); int len; while (m--) { len = 0; while (c = getchar()) { if (c == '\n') break; if (n[len] == 0 && c != '?') n[len] = c; else if (n[le...
### Prompt Construct a Cpp code solution to the problem outlined: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string me...
#include <bits/stdc++.h> using namespace std; int n, len = 0, flen = 0; string a[100001]; char temp[100001], ans[100001]; void init() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", &temp); a[i] = temp; len = a[i].size(); if (len > flen) flen = len; for (int j = 0; j < len; j++) { ...
### Prompt In CPP, your task is to solve the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meet...
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; long long modpow(long long x, unsigned long long y) { long long res = 1; x = x % M; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % M; y = y >> 1; x = (x * x) % M; } return res; } int main() { ios_base::syn...
### Prompt Your challenge is to write a Cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; for (int j = 0; j < n - 1; j++) { string t; cin >> t; for (int i = 0; i < t.length(); i++) if (t[i] != '?' && t[i] != s[i]) if (s[i] == '?') s[i] = t[i]; else s...
### Prompt In cpp, your task is to solve the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meet...
#include <bits/stdc++.h> const double eps = 1e-7; const int inf = 0x7FFFFFFF; using namespace std; char buf[100010]; char idx[100010], ans[100010]; int main() { int n, l; cin >> n; for (int i = 0; i < n; i++) { scanf("%s", buf); l = strlen(buf); if (!i) { for (int j = 0; j < l; j++) idx[j] = buf...
### Prompt Your challenge is to write a cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; vector<string> v(n); for (string &i : v) cin >> i; vector<char> at(v[0].length(), '.'); for (string i : v) { for (long long j = 0; j < i.length(); ++j) { ...
### Prompt Develop a solution in Cpp to the problem described below: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; for (int i = 1; i < n; i++) { string ss; cin >> ss; for (int j = 0; j < s.length(); j++) if (ss[j] != '?' && ss[j] != s[j]) if (s[j] == '?') s[j] = ss[j]; else ...
### Prompt Generate a CPP solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets t...
#include <bits/stdc++.h> using namespace std; char a[100000]; int main() { int n; cin >> n; for (int i = 0; i < 100000; i++) { a[i] = '?'; } string s; for (int i = 0; i < n; i++) { cin >> s; for (int j = 0; j < s.size(); j++) { if (a[j] == '?' && s[j] != '?') { a[j] = s[j]; }...
### Prompt Please provide a CPP coded solution to the problem described below: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, len; cin >> n; char cur[100100]; for (int i = 0; i < 100000; i++) cur[i] = '0'; for (int i = 0; i < n; i++) { string ss; cin >> ss; len = ss.size(); for (int j = 0; j < ss.size(); j++) { ...
### Prompt Please formulate a Cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int n, m, ans, cnt; char c[N]; char k; string a[N]; bool flag; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < a[0].size(); i++) { k = 'a'; flag = false; for (int j = 0; j < n; j++) if...
### Prompt Construct a Cpp code solution to the problem outlined: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string me...
#include <bits/stdc++.h> using namespace std; char ch[100010], temp[100010]; bool ok[100010]; int main() { int n; cin >> n; cin >> ch; int m = strlen(ch); for (int i = 1; i < n; i++) { cin >> temp; for (int j = 0; j < m; j++) { if (ch[j] >= 'a' && ch[j] <= 'z' && temp[j] >= 'a' && temp[j] <= 'z'...
### Prompt Develop a solution in cpp to the problem described below: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string...
#include <bits/stdc++.h> using namespace std; set<int> s[100001]; int main() { int n, i, l, k; string a; scanf("%d", &n); for (i = 0; i < n; i++) { cin >> a; for (l = 0; l < a.size(); l++) { if (a[l] != '?') s[l].insert(a[l]); } k = a.size(); } for (i = 0; i < k; i++) { if (s[i].si...
### Prompt Your challenge is to write a CPP solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; const int N = (int)(1e5 + 20); const long long int INF = (1ll << 62); int main() { ios_base::sync_with_stdio(0); int n; cin >> n; vector<string> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; int m = v[0].length(); for (int i = 0; i < m; ++i) { int last = ...
### Prompt Construct a CPP code solution to the problem outlined: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string me...
#include <bits/stdc++.h> using namespace std; char ar[100005]; int main() { int n; cin >> n; for (int i = 0; i < 100005; ++i) ar[i] = '?'; int ln; int t = n; while (n--) { string str; cin >> str; ln = str.length(); for (int i = 0; i < str.length(); ++i) { if (ar[i] == '?' && str[i] != ...
### Prompt Generate a Cpp solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets t...
#include <bits/stdc++.h> using namespace std; int n; char abc[100005]; int main() { ios::sync_with_stdio(false); cin >> n; memset(abc, 0, sizeof(abc)); string str; for (int i = 0; i < n; i++) { cin >> str; for (size_t j = 0; j < str.size(); j++) { if (abc[j] == 0 && str[j] != '?') abc[j]...
### Prompt Please provide a CPP coded solution to the problem described below: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particu...
#include <bits/stdc++.h> using namespace std; int MIN(int a, int b) { int x = (b > a) ? a : b; return x; } int MAX(int a, int b) { int x = (b < a) ? a : b; return x; } const int size = 1000007; const long long modulo = 1000000007; const long long inf = 1e18; const double eps = 1e-6; long long n, m, a[4000], b[4...
### Prompt Generate a CPP solution to the following problem: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets t...
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9 + 7; const int MXN = (int)1e5 + 7; int n, k, t; int fac[MXN], rev[MXN], m[MXN]; int binpow(int x, int y) { int res = 1; while (y) { if (y & 1) res = (1LL * res * x) % INF; y >>= 1; x = (1LL * x * x) % INF; } return res; } int c(i...
### Prompt Please create a solution in CPP to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const ui...
### Prompt Generate a CPP solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ...
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize("Ofast", "-funroll-loops", "-fdelete-null-pointer-checks") #pragma GCC target("ssse3", "sse3", "sse2", "sse", "avx2", "avx") using namespace std; const long long inf = 0x7f7f7f7f7f7f; long long read() { long long x = 0, f = 1; char c = getchar();...
### Prompt Your task is to create a cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ...
#include <bits/stdc++.h> #pragma GCC optimize("O3") const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 1e5 + 5; const double eps = 1e-9; using namespace std; long long fac[MAXN], inv[MAXN]; int sieve[MAXN], cnt[MAXN], fl[MAXN]; long long bin(long long a, long long b) { long...
### Prompt Develop a solution in Cpp to the problem described below: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; long long n, m, a, b, c, k, temp, x, y; const int MAXN = 1e5 + 11; inline long long max(long long a, long long b) { return ((a > b) ? a : b); } inline long long min(l...
### Prompt In CPP, your task is to solve the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ...
#include <bits/stdc++.h> using namespace std; template <typename T> void r1(T &x) { x = 0; char c(getchar()); int f(1); for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1; for (; '0' <= c && c <= '9'; c = getchar()) x = (x * 10) + (c ^ 48); x *= f; } const long long maxn = 4e5 + 5; const lon...
### Prompt Develop a solution in cpp to the problem described below: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; long long P[100005], Inv[100005]; long long f1(long long x, long long y) { long long res = 1; while (y) { if (y & 1) res = res * x % 1000000007; x = x * x % 1000000007; y >>= 1; } return res; } int prm[100005], Q[100005], mu[100005], pri; void Init() { ...
### Prompt Create a solution in Cpp for the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t...
#include <bits/stdc++.h> using namespace std; long long exp(long long b, long long e) { if (b == 1 || e == 0) return 1; if (e == 1) return b % 1000000007; if (e == 2) return (b * b) % 1000000007; return (((e & 1) == 0) ? exp(exp(b, e >> 1), 2) % 1000000007 : (b * (exp(exp(b, e >> 1),...
### Prompt Please create a solution in Cpp to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> const int Max_N = 9 + (int)1e5; const long long mod = 7 + (int)1e9; int fac[Max_N], fac_inv[Max_N], inv[Max_N], clk, ans[Max_N], flag[Max_N]; std::vector<int> aaaa1111[Max_N]; void add(int &a, int b) { a += b; if (a >= mod) a -= mod; } void init(int n) { fac_inv[0] = fac[0] = 1; for (in...
### Prompt Your task is to create a CPP solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, mN = 1e5 + 100; int add(int a, int b) { a += b; if (a < 0) a += mod; if (a >= mod) a -= mod; return a; } int mul(int a, int b) { long long ret = 1LL * a * b; if (ret >= mod) ret %= mod; return ret; } int pwm(int a, long long p) { int...
### Prompt In Cpp, your task is to solve the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ...
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 1e5 + 4; constexpr long long mods = 1e9 + 7; int prm[maxn], pc = 0; int vis[maxn], mu[maxn]; long long fac[maxn]; inline long long modpow(long long a, int p = mods - 2) { long long res = 1; while (p) { if (p & 1) (res *= a) %= mods; (a *= a)...
### Prompt Your task is to create a cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int lim = 1e5; int t, x, n, fac[100005], inv[100005]; long long res; int read() { int x = 0, fl = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') fl = -1; ch = getchar(); } while (ch >= '0' && ch <= '9')...
### Prompt In cpp, your task is to solve the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ...
#include <bits/stdc++.h> using namespace std; const long long sz = 1e5 + 10, mod = 1e9 + 7; vector<long long> dv[sz]; long long dp[sz], fact[sz], inv[sz]; long long fastPow(long long x, long long n, long long MOD) { long long ret = 1; while (n) { if (n & 1) ret = (ret * x) % MOD; x = (x * x) % MOD; n >>...
### Prompt Please create a solution in Cpp to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") #pragma GCC optimize("no-stack-protector,fast-math") using namespace std; const long long N = 2e5 + 100, OO = 1e9 + 7, T = 1e6 + 10, M = 1e9 + 7, P = 6151, SQ = 280, lg = 20; long long fac[N], inv[N], flag[N]; long lo...
### Prompt Your challenge is to write a CPP solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int MOD = 1e9 + 7; vector<int> vec; int fact[N], ive_fact[N]; int power(int x, int n) { int ans = 1; while (n) { if (n & 1) ans = (1ll * ans * x) % MOD; n /= 2; x = (1ll * x * x) % MOD; } return ans; } void init() { fact[0]...
### Prompt Please create a solution in Cpp to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; using ull = unsigned long long; using ll = long long; using ld = long double; const int mod = 1e9 + 7; const int inf = INT_MAX; const int N = 1e5; ll modexp(ll x, ll n) { ll ans = 1; while (n) { if (n & 1) ans = ans * x % mod; x = x * x % mod; n /= 2; } ...
### Prompt Please formulate a Cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; template <class T> T gcd(T x, T y) { while (T t = x % y) x = y, y = t; return y; } const double eps = 1e-9; const double PI = acos(-1.); const int INF = 1000000000; const int MOD = 1000000007; const double E = 2.71...
### Prompt Your task is to create a cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int kMaxN = 1e5 + 7; constexpr ll mod = 1e9 + 7; int lp[kMaxN]; vector<int> primes; ll ans[kMaxN]; ll f[2 * kMaxN]; ll fi[2 * kMaxN]; ll powmod(ll a, ll b) { ll res = 1; while (b) { if (b & 1) { res = res * a % mod; } a ...
### Prompt Please provide a Cpp coded solution to the problem described below: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w...
#include <bits/stdc++.h> using namespace std; const int MAX_SIZE = 100500; const int mod = (int)1e9 + 7; int t, n, k; long long fact[MAX_SIZE]; long long inv[MAX_SIZE]; long long m[MAX_SIZE]; long long binpow(long long a, int b) { if (!b) { return 1; } else if (b & 1) { return (binpow(a, b - 1) * 1ll * a) %...
### Prompt Your task is to create a CPP solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ...
#include <bits/stdc++.h> using namespace std; const long long inf = 2e18 + 7; const long long mod = 1e9 + 7; const double eps = 1e-7; const double PI = 2 * acos(0.0); const double E = 2.71828; long long fact[100005], ifact[100005]; int cnt[100005]; long long inv(long long x) { long long n = mod - 2; long long res =...
### Prompt Create a solution in Cpp for the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 100; int mob[maxn]; vector<int> v1[maxn]; bool isPrime[maxn]; bool sq[maxn]; int fact[maxn], rfact[maxn]; int pw(int a, int b) { if (b == 0) return 1; int temp = pw(a, b / 2) % 1000000007; if (b % 2) { return (1ll * (1ll * a * temp) % 100000...
### Prompt Develop a solution in CPP to the problem described below: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; const int maxN = 100 * 1000 + 5; const long long mod = 1000 * 1000 * 1000 + 7; int pi[maxN]; long long mul(long long x, long long y) { return (x * y) % mod; } long long add(long long x, long long y) { return (x + y + mod) % mod; } long long pw(long long x, int k) { if (k ...
### Prompt Construct a CPP code solution to the problem outlined: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien...
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long long ff[100100], inv_ff[100100]; int q, n, f, prime[100100], sqr[100100], mu[100100], ans; vector<int> divi[100100]; long long inv_mod(long long x) { long long ret = 1LL, y = MOD - 2; while (y) { if (y % 2) ret = (ret * x) % MOD; ...
### Prompt Generate a cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; const int MAX = 1e5 + 5; const int P = (1 << 6) + 5; const int MOD = 1e9 + 7; const int64_t INF = INT_MAX; const int64_t _INF = I...
### Prompt Generate a cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-12; const int inf = 2000000000; int MOD = 1000000007; int MOD1 = 1000000007; int MOD2 = 1000000009; inline bool checkBit(long long int n, long long int i) { return n & (1LL << i); } inline long long int setBit(long long in...
### Prompt Construct a Cpp code solution to the problem outlined: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien...
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7, maxn = 1e5; int n, f; long long P[maxn], D[maxn]; vector<int> facs; map<pair<int, int>, int> ans; int Pow(int x, int k) { if (k == 0) return 1; long long tmp = Pow(x, k >> 1); tmp = (tmp * tmp) % M; if (k & 1) return (tmp * x) % M; else ...
### Prompt Please formulate a Cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 * 1000 + 10; const int MOD = 1000 * 1000 * 1000 + 7; vector<int> dv[MAXN]; int f; long long int dp[MAXN]; int mark[MAXN]; int zz; long long int po(long long int p, long long int b) { if (!p) return 1; long long int r = po(p / 2, b); r = (r * r) % ...
### Prompt In Cpp, your task is to solve the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ...
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long long ff[100100], inv_ff[100100], ans; int q, n, f, prime[100100], sqr[100100], mu[100100]; vector<int> divi[100100]; long long inv_mod(long long x) { long long ret = 1LL, y = MOD - 2; while (y) { if (y % 2) ret = (ret * x) % MOD; ...
### Prompt Generate a CPP solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:16777216") using namespace std; long long fact[100005]; int q, used[100005], dp[100005], deg[100005]; vector<int> divisors[100005]; int power(long long a, long long b) { if (!b) return 1; long long t = power(a, b / 2); if (b % 2) return (((t * t) % 1000...
### Prompt Please provide a CPP coded solution to the problem described below: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w...
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& a) { return os << "(" << a.first << "," << a.second << ")"; } template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << (*i) << " "; cout << endl; } template <class T> v...
### Prompt Create a solution in CPP for the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t...
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, int> dp; int f[200001], t, n, m, d[20]; int binpow(int a, int b) { int res = 1; while (b) { if (b & 1) res = (res * 1ll * a) % 1000000007; b >>= 1; a = (a * 1ll * a) % 1000000007; } return res; } int get_c(int n, int k) { return f[n...
### Prompt In Cpp, your task is to solve the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ...
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long long ff[100100], inv_ff[100100], ans; int q, n, f, prime[100100], sqr[100100], mu[100100]; vector<int> divi[100100]; long long inv_mod(long long x) { long long ret = 1LL, y = MOD - 2; while (y) { if (y % 2) ret = (ret * x) % MOD; ...
### Prompt Construct a Cpp code solution to the problem outlined: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien...
#include <bits/stdc++.h> const double EPS = 1e-24; const long long int MOD = 1000000007ll; const double PI = 3.14159265359; int INF = 2147483645; template <class T> T Max2(T a, T b) { return a < b ? b : a; } template <class T> T Min2(T a, T b) { return a < b ? a : b; } template <class T> T Max3(T a, T b, T c) { r...
### Prompt Generate a Cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long mod = 1e9 + 7; long long fact[N], inv[N]; long long dp[N]; int done[N]; int q; int id; vector<long long> g[N]; long long bigmod(long long x, long long y) { long long res = 1; while (y) { if (y & 1) res = (res * x) % mod; y ...
### Prompt Create a solution in Cpp for the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t...
#include <bits/stdc++.h> using namespace std; int mpow(int base, int exp); void ipgraph(int m); void dfs(int u, int par); const int mod = 1000000007; const int N = 3e5, M = N; long long fac[N], ifac[N]; vector<int> g[N]; int a[N]; long long ff(int n, int f) { n--, f--; if (n < f) return 0; long long ans = fac[n];...
### Prompt Construct a cpp code solution to the problem outlined: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien...
#include <bits/stdc++.h> using namespace std; int fact[1000000], d[1000000], l; inline int Pow_Log(int x, int p) { int sol = 1; while (p) { if (p & 1) { sol = (1LL * sol * x) % 1000000007; --p; } p >>= 1; x = (1LL * x * x) % 1000000007; } return sol; } inline int Comb(int n, int k) {...
### Prompt Your task is to create a cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ...
#include <bits/stdc++.h> using namespace std; const int m = pow(10, 9) + 7; int fact[100001], rev_fact[100001]; vector<int> divisors[1000001]; int* num_of_dis; bool* check; int expmod(int a, int b) { int result = 1; while (b > 0) { if (b % 2 > 0) result = (result * (unsigned long long)a) % m; a = (a * (unsi...
### Prompt In Cpp, your task is to solve the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ...
#include <bits/stdc++.h> using namespace std; long long fact[200000], invf[200000]; long long mod_pow(long long a, long long b) { if (b == 0) return 1; if (b % 2 == 1) return (a * mod_pow(a, b - 1)) % 1000000007LL; long long ans = mod_pow(a, b / 2); return (ans * ans) % 1000000007LL; } void gen_fact() { fact[...
### Prompt Construct a CPP code solution to the problem outlined: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien...
#include <bits/stdc++.h> using namespace std; long long mul[100010]; long long in[100010]; long long v[100010]; void extend_gcd(long long a, long long b, long long &d, long long &x, long long &y) { if (!b) { d = a; x = 1; y = 0; } else { extend_gcd(b, a % b, d, y, x); y -= x * (a...
### Prompt Please provide a CPP coded solution to the problem described below: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w...
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long long ff[100100], inv_ff[100100]; int q, n, f, prime[100100], sqr[100100], mu[100100], ans; vector<int> divi[100100]; long long inv_mod(long long x) { long long ret = 1LL, y = MOD - 2; while (y) { if (y & 1) ret = (ret * x) % MOD; ...
### Prompt In CPP, your task is to solve the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ...
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; int pri[20], fac[100005], rfac[100005]; int mo[40005], A[40005]; int fast(int a, int b) { int sum = 1; while (b > 0) { if (b & 1) sum = 1ll * sum * a % P; a = 1ll * a * a % P; b >>= 1; } return sum; } void add(int &a, int b) { a ...
### Prompt Generate a CPP solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ...
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T &x) { int f = 1; x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } x *= f; } con...
### Prompt Develop a solution in cpp to the problem described below: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int MOD = 1000000007; long long mu[MAXN], pr[MAXN]; long long fact[MAXN], inv[MAXN]; void compute_mu() { for (int i = 1; i < MAXN; i++) mu[i] = -1, pr[i] = 1; for (int i = 2; i < MAXN; i++) { if (pr[i]) { mu[i] = 1; for (in...
### Prompt Your challenge is to write a Cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w...
#include <bits/stdc++.h> const int mod = 1e9 + 7; const int w = 1e5; std::map<std::pair<int, int>, int> st; std::vector<int> d[w + 10]; int a[w + 10]; int ft[w + 10]; inline int pmod(int a, int b) { int res = 1; while (b) { if (b & 1) res = (1ll * res * a) % mod; a = (1ll * a * a) % mod; b >>= 1; } ...
### Prompt Your task is to create a CPP solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ...
#include <bits/stdc++.h> using namespace std; int mu[100010], lst[100010], can[100010], flag[100010], pr[100010]; const long long Mod = 1000000007LL; long long fac[100010], inv[100010]; long long exp(int a, long long b, long long c) { long long ans = 1, num = a; while (b > 0) { if (b % 2 == 1) ans = ans * num %...
### Prompt Please formulate a CPP solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; int const N = 1e5 + 20, mod = 1e9 + 7; int q, n, f; int fac[N], rev[N]; bool np[N]; vector<int> vec[N]; inline void rel(int &a) { if (a < 0) a += mod; if (a >= mod) a -= mod; } inline int pw(int a...
### Prompt Please create a solution in cpp to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long mod = 1e9 + 7; long long fact[N], inv[N]; long long dp[N]; int done[N]; int q; int id; long long n, f; vector<long long> prime; vector<long long> g[N]; long long mobius[N]; bool composite[N]; void mobi() { memset(composite, false, si...
### Prompt Your task is to create a Cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ...
#include <bits/stdc++.h> using namespace std; const long long N = 200000; long long mod = 1e9 + 7; long long fac[N]; long long power(long long n, long long k) { if (k == 0) { return 1; } else { if (k % 2 == 0) { long long x = power(n, k / 2); return x * x % mod; } else { long long x = ...
### Prompt Construct a Cpp code solution to the problem outlined: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int di[maxn][300]; int usado, mk[maxn]; long long fa[maxn]; long long in[maxn]; long long dp[maxn]; int cont[maxn]; long long power(long long a, long long b) { if (b == 0) return 1; if (b == 1) return a; if (b % 2) return (power(a, b - 1) * a)...
### Prompt Please formulate a Cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 10; const int MOD = 1000000007; map<pair<long long, long long>, long long> dp; long long A[MAX], B[MAX]; long long Qmod(long long x, long long n) { long long res = 1; while (n > 0) { if (n & 1LL) res = res * x % MOD; x = x * x % MOD; n ...
### Prompt Please provide a cpp coded solution to the problem described below: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w...
#include <bits/stdc++.h> using namespace std; struct node { int nxt, t; } A[1166900]; int head[100010], node_cnt; void add_edge(int x, int y) { A[node_cnt] = (node){head[x], y}; head[x] = node_cnt++; } int pri[100010], pri_cnt, mu[100010]; bool mark[100010]; void sieve() { int i, j; mu[1] = 1; for (i = 2; i...
### Prompt Please formulate a cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 30, Mod = 1e9 + 7; const long long SQ = 330; long long dp[N]; vector<long long> Div[N]; long long f[N], I[N]; bool vis[N]; inline long long _sub(long long x, long long y) { long long res = x - y; if (res < 0) res += Mod; res %= Mod; return ...
### Prompt Please create a solution in cpp to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int fac[100001], inv[100001]; vector<int> e[100001]; bool v[100001]; int cnt, p[100001], mu[100001]; inline int ksm(long long base, int expo) { long long ret = 1; for (; expo; (base *= base) %= mod, expo >>= 1) if (expo & 1) (ret *= base)...
### Prompt Please formulate a Cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int p[100010], cnt, miu[100010]; bool vis[100010]; long long fac[100010], inv[100010], facinv[100010]; void init() { miu[1] = 1; for (int i = 2; i <= 100000; i++) { if (!vis[i]) { p[++cnt] = i; miu[i] = -1; } for (i...
### Prompt Create a solution in cpp for the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t...
#include <bits/stdc++.h> long long ans, f[100010], i, tot, g[100010], a, b, c, n, j; void exgcd(long long a, long long b, long long &x, long long &y) { long long t; if (b == 0) { x = 1; y = 0; return; } exgcd(b, a % b, x, y); t = x; x = y; y = t - a / b * y; } long long cnt(int a, int b) { l...
### Prompt Please create a solution in Cpp to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const long long MOD = 1e9 + 7; long long fact[N]; long long invfact[N]; long long mod_pow(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } inline ...
### Prompt Develop a solution in Cpp to the problem described below: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr...
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { T r; while (b != 0) { r = a % b; a = b; b = r; } return a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T...
### Prompt Your challenge is to write a Cpp solution to the following problem: Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w...