output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> c(k);
for... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 9;
long long cnt[N];
vector<long long> v, ans[N];
int32_t main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
long long n, k;
cin >> n >> k;
for (long long i = (long long)(1); i <= (long long)(n); i++) {
long long x;
cin >> x... | ### Prompt
Please provide a CPP coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 23333333333333333;
const int INF = 0x3f3f3f3f;
const int maxn = 2e5 + 15;
long long a[maxn];
long long sum[maxn];
long long b[maxn];
long long c[maxn];
long long k;
vector<long long> v[maxn];
bool check(long long mid) {
for (long long i = 1; k >= i; ... | ### Prompt
Develop a solution in Cpp to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 10;
const double PI = cos(-1.0);
int a[mx], c[mx];
vector<int> b[mx];
int cmp(int a, int b) { return a > b; }
int main() {
int n, m, j = 1, ans = 0, l, r, lx, ly, mid;
cin >> n >> m;
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = ... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void mine(T1 &x, T2 y) {
if (x > y) x = y;
}
template <typename T1, typename T2>
inline void maxe(T1 &x, T2 y) {
if (x < y) x = y;
}
ostream &operator<<(ostream &a, const vector<long long> &b) {
for (auto k : b) cout << k << ... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
long long powerm(long long x, unsigned long long y, long long p) {
long long res = 1;
x = x % p;
if (x == 0) return 0;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
struct node {
long long fmax = -1000... | ### Prompt
Generate a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each test... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cout.tie(nullptr);
int n, k;
cin >> n >> k;
vector<int> m(n), c(k);
for (int i = 0; i < n; ++i) cin >> m[i];
for (int i = 0; i < k; ++i) cin >> c[i];
sort(m.begin(), m.end());
int ans = 0;
for (int i = 0; i < n; ... | ### Prompt
Develop a solution in cpp to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
using namespace std;
const long long maxn = 2e5 + 100, inf = 1e18, LOG = 23, mod = 1e9 + 7;
int block = 300, timer = 0;
const long double EPS = 1e-7;
int n, x, k, a[maxn], c[... | ### Prompt
Generate a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each test... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
int c[maxn];
multiset<int> s;
multiset<int>::iterator pos;
vector<int> v[maxn];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
int x;
cin >... | ### Prompt
Please provide a CPP coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9 + 5;
const int MOD = 998244353;
const long long ooll = 1e18 + 5;
const int N = 1e6 + 5;
int v[N], back[N], c[N];
void solve() {
int n, k, i, j, m;
cin >> n >> k;
for (i = 1; i <= n; ++i) cin >> v[i];
for (i = 1; i <= k; ++i) cin >> c[i];
int p =... | ### Prompt
Create a solution in cpp for the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each te... |
#include <bits/stdc++.h>
using namespace std;
int n, k, a[200009], c[200009];
vector<int> v[200009];
set<pair<int, int> > s;
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
ios_base::sync_with_stdio(0);
cin >> n >> k;
for (int i = 0, x; i < n; i++) {
cin >> x;
x--;
a[x]++;
}
f... | ### Prompt
Create a solution in Cpp for the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each te... |
#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9 + 9;
const long long inf = 1e18 + 18;
const int max6 = 1e6 + 6;
const int modx = 1e9 + 123;
const int mody = 997;
const int base = 137;
int a[max6], b[max6];
vector<int> g[max6];
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; ++i) cin... | ### Prompt
Your task is to create a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initia... |
#include <bits/stdc++.h>
using namespace std;
int m[200010], c[200010], a[200010];
vector<int> v[200050];
bool cmp(int x, int y) { return x > y; }
int main() {
int n, k, i, ans = 1;
cin >> n >> k;
for (i = 1; i <= n; i++) {
cin >> m[i];
a[m[i]]++;
}
for (i = 1; i <= k; i++) cin >> c[i];
for (i = k; ... | ### Prompt
Please provide a cpp coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = LLONG_MAX;
void solve() {
long long n, k;
cin >> n >> k;
vector<long long> m(n), suf(k + 1, 0), cnt(k + 1, 0), c(k + 1);
for (long long i = 0; i < n; i++) {
cin >> m[i];
cnt[m[i]]++;
}
for (long long i = 1; i <= k; i++) {
cin >>... | ### Prompt
Please formulate a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
constexpr long long inf = 1000000000;
constexpr long long INF = 1000000000000000010;
constexpr long double EPS = 1e-12;
constexpr long double PI = 3.141592653589793238;
template <class T, class U>
inline bool c... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, k, ans;
int m[N], c[N], cnt[N], sp[N], top;
multiset<int> S[N];
multiset<int>::iterator it;
bool check(int x) {
for (int i = 1; i <= n; i++) S[i].clear();
for (int i = 1; i <= n; i++) sp[i] = c[1];
int mx = 1, t = 0;
ans = 0;
for (int... | ### Prompt
Your task is to create a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initia... |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
bool mod(long double a, long double b) { return a / b - floor(a / b); }
vector<long long> dp[200005];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
os << "{" << p.first << "," << p.second << "}";
return os;
}
const int N = 3e5 + 5;
const int oo = 1e9 + 7;
int n, k;
int c[N];
int m[N];
bool pos(int len) {
priority_queue<int> pq... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 7;
int n, k;
int m[maxn], a[maxn];
long long sum[maxn];
int vis[maxn];
struct node {
int l, r, w;
long long v;
} T[maxn];
int l = 1, cnt = 0;
vector<int> g[maxn];
int main() {
scanf("%d%d", &n, &k);
for (int i = ... | ### Prompt
Please formulate a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
int const MAXN = 2e6 + 9;
int a[MAXN], c[MAXN], b[MAXN];
set<pair<int, int>> st;
vector<vector<int>> adj;
int sz = 0;
void get(int i) {
int idx = (int)adj.size() - 1;
while ((int)adj[idx].size() < c[i] && a[i]) {
a[i]--;
adj[idx].push_back(i);
if (a[i] == 0)... | ### Prompt
Please create a solution in cpp to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
scanf("%d%d", &n, &k);
vector<int> a(n);
for (int i = 0; i < int(n); i++) scanf("%d", &a[i]);
vector<int> c(k + 1);
for (int i = 0; i < int(k); i++) scanf("%d", &c[i + 1]);
sort(a.begin(), a.end(), greater<int>());
int ans = 0;
for (... | ### Prompt
Develop a solution in CPP to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(vector<T> &v, int n) {
for (int i = 0; i < n; i++) cin >> v[i];
}
template <typename T>
inline void read(T &n) {
cin >> n;
}
inline void read(string &s) { cin >> s; }
template <typename T>
inline void dbgc(const char *txt, T &c) {
... | ### Prompt
Construct a cpp code solution to the problem outlined:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
void print(vector<long long> &v) {
for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
cout << '\n';
}
long long power(long long a, long long b) {
long long res = 1;
while (b != 0) {
if (b & 1) {
res *= a... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 10;
const long long LNF = 2e18;
int n, k, S[MAX], C[MAX];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> S[i];
for (int i = 1; i <= k; i++) ci... | ### Prompt
Please create a solution in cpp to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios ::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k;
cin >> n >> k;
vector<int> m(n), c(k);
for (int i = 0; i < n; i++) cin >> m[i];
for (int i = 0; i < k; i++) cin >> c[i];
sort(m.rbegin(), m.rend());
vector<vector<int>> groups;
... | ### Prompt
Please formulate a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
long long arr[k + 1];
long long c[k + 1];
memset(arr, 0, sizeof(arr));
for (int i = 0; i < n; i++) {
long long a;
cin >> a;
arr[a]++;
}
for (int i = 1; i <= k; i++) cin >> c[i];
long long dea[k + 1];
... | ### Prompt
Develop a solution in cpp to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int n, k;
vector<int> countSort(vector<int> arr, vector<int> count_for_sort) {
vector<int> a(n);
for (long long i = 1; i < k + 1; i++) {
count_for_sort[i] += count_for_sort[i - 1];
}
for (long long i = 0; i < n; i++) {
a[count_for_sort... | ### Prompt
Please create a solution in Cpp to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
int m[200005], c[200005];
void solve() {
int n, k;
scanf("%d %d ", &n, &k);
multiset<int> s;
for (int i = 0; i < n; ++i) {
scanf("%d ", &m[i]);
s.insert(m[i]);
}
for (int i = 1; i <= k; ++i) {
scanf("%d ", &c[i]);
}
vector<vector<int> > out;
wh... | ### Prompt
Construct a cpp code solution to the problem outlined:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
scanf("%d%d", &n, &k);
multiset<int> st;
for (int i = 0; i < n; i++) {
int a;
scanf("%d", &a);
st.insert(a);
}
vector<int> h(k), bf(k, -1);
for (int i = 0; i < k; i++) {
scanf("%d", &h[i]);
if (i) {
if (h[i] < h... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
int main() {
set<pair<long long int, long long int>> ans;
long long int n, k;
cin >> n >> k;
long long int arr[k + 1];
long long int ts;
memset(arr, 0, sizeof(arr));
for (int i = 0; i < n; i++) {
cin >> ts;
arr[ts]++;
}
long long int cost[k + 1];
... | ### Prompt
Please formulate a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int SINF = 1000000009;
const ll INF = 1000000000000000018;
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << p.first << " " << p.second;
return os;
}
template <typename T, ... | ### Prompt
Develop a solution in CPP to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
template <typename T>
void scan(T &x) {
x = 0;
bool _ = 0;
T c = getchar();
_ = c == 45;
c = _ ? getchar() : c;
while (c < 48 || c > 57) c = getchar();
for (; c < 48 || c > 57; c = getchar())
;
for (; c > 47 && c < 58; c = getchar()) x = (x << 3) + (x << 1) + (c & 15);
x =... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
long long int h[400005];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int n, m;
cin >> n >> m;
long long int a[n], b[m];
for (long long int i = 0; i < n; i++) cin >> a[i];
for (long long int i = 1; i <= m; i++) {
l... | ### Prompt
Develop a solution in Cpp to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const double PI = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long N = 2e5 + 10;
long long cnt[N];
long long c[N];
long long n, k;
int32_t main() {
ios::sync_with_stdio(0... | ### Prompt
In CPP, your task is to solve the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each t... |
#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433;
const long long mod = 1000000007;
const long long inf = 3e18;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long n, k;
cin >> n >> k;
vector<long long> m(n);
for (long long i = 0; i ... | ### Prompt
Create a solution in CPP for the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each te... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
void printvec(vector<T>& x, int a, int b) {
for (int i = (a); i <= (b); i++) cout << x[i] << " ";
cout << "\n";
}
const double PI = acos((double)-1);
const double EPSILON = 1e-7;
const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const long long MOD = 1e9... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
int c[200010];
int cnt[200010];
vector<vector<int> > ans;
vector<int> seq;
vector<int> add[200010];
int nxt[200010];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int temp;
int n, k;
cin >> n >> k;
for (int i = 0; i < n; ++i) {
cin >> temp... | ### Prompt
Your task is to create a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initia... |
#include <bits/stdc++.h>
using namespace std;
template <typename A>
using VE = vector<A>;
template <typename A>
using USET = unordered_set<A>;
template <typename A>
using HEAP = priority_queue<A>;
template <typename A, typename B>
using PA = pair<A, B>;
template <typename A, typename B>
using UMAP = unordered_map<A, B>... | ### Prompt
Please provide a CPP coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const int MX = 2e5 + 5, INF = 1000000000;
int arr[MX], mx[MX], n, k;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for (int i = 0; i < n; i++) cin >> arr[i];
for (int i = 1; i <= k; i++) cin >> mx[i];
sort(arr, arr + n, greater<int>());
vect... | ### Prompt
Please formulate a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
long long modulo(long long base, long long exponent, long long modulus);
long long choose(long long n, long long k);
long long inverse(long long a, long long m);
void build();
void fileio();
long long ncr(long long n, long long r);
const int nax = 1e6 + 10;
const int LG = l... | ### Prompt
Create a solution in cpp for the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each te... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int N = 200005;
i... | ### Prompt
Develop a solution in CPP to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
int a[200010], cnt[200010], sum[200010], xian[20010];
void solve() {
int n, k;
cin >> n >> k;
if ((1) <= (n))
for (register int i = (1); i <= (n); i++) {
cin >> a[i];
cnt[a[i]]++;
}
sort(a + 1, a + n + 1);
if ((1) <= (k))
for (register int ... | ### Prompt
Develop a solution in Cpp to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, k;
cin >> n >> k;
long long m[n], c[k];
map<long long, long long> mp;
for (long long i = 0; i < n; i++) cin >> m[i];
for (long long i = 0; i < k; i++) cin >> c[i];
sort(m, m + n... | ### Prompt
Generate a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each test... |
#include <bits/stdc++.h>
using namespace std;
int n, k, a[200009], c[200009];
vector<int> v[200009];
set<pair<int, int> > s;
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
ios_base::sync_with_stdio(0);
cin >> n >> k;
for (int i = 0, x; i < n; i++) {
cin >> x;
x--;
a[x]++;
}
for (int i = 0; ... | ### Prompt
Create a solution in CPP for the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each te... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 10000;
const long long inf = 10000000000000000;
int random(int n) { return (long long)rand() * rand() % n; }
inline int read() {
int f = 1, num = 0;
char ch = getchar();
while (0 == isdigit(ch)) {
if (ch == '-') f = -1;
... | ### Prompt
Please formulate a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
vector<int> G[200005];
int main() {
int t, n, m, l, r, ar, id = 0;
cin >> n >> m;
vector<int> vc;
for (int i = 1; i <= n; i++) {
cin >> ar;
vc.push_back(ar);
}
sort(vc.begin(), vc.end());
for (int i = 1; i <= m; i++) {
cin >> ar;
l = n - (lower... | ### Prompt
Please formulate a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e5 + 5, MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long i, j, k, n;
cin >> n >> k;
vector<long long> m(n), c(k + 5);
vector<long long> cnt(k + 5);
set<int, greater<int> > s, s1;
set<int, greater... | ### Prompt
Create a solution in cpp for the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each te... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v, c, freq;
bool check(long long m) {
int k = (int)freq.size() - 1;
long long myCap = m * c[1], reqCap = 0;
int i = 1;
while (i <= k) {
myCap = min(myCap, m * c[i]);
reqCap = freq[i];
if (myCap < reqCap) {
return false;
}
myCap ... | ### Prompt
Develop a solution in CPP to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
vector<int> G[200005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t, n, m, l, r, ar, id = 0;
cin >> n >> m;
vector<int> vc;
for (int i = 1; i <= n; i++) {
cin >> ar;
vc.push_back(ar);
}
sort(vc.begin(), vc.end());
for (int i ... | ### Prompt
Please formulate a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 7;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
int col[k + 1], h[k + 1];
fill(col, col + k + 1, 0);
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
col[x]++;
}
for (int i = 1; i < k + 1; ... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 998244353;
int a[N], b[N], c[N];
vector<int> t[N];
int main() {
int n, k;
cin >> n >> k;
memset(b, 0, sizeof(b));
for (int i = 1; i <= n; i++) {
scanf("%d", a + i);
b[a[i]]++;
}
for (int i = 1; i <= k; i++) {
s... | ### Prompt
Your task is to create a CPP solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initia... |
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int dr8[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dc8[] = {1, -1, 0, 0, -1, 1, -1, 1};
int dr4[] = {0, 1, -1, 0};
int dc4[] = {1, 0, 0, -1};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, k;
cin >> n >> k;
l... | ### Prompt
Please create a solution in CPP to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, k;
cin >> n >> k;
long long a[n + 5];
long long i;
for (i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<long long>());
long long c[k + 5];
for (i = 1; i <= k; i++) cin >> c[i];... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
while (t--) {
int n, k;
cin >> n >> k;
vector<int> m(n), c(k + 1), cnt(k + 1, 0);
for (int i = 0; i < n; i++) {
cin >> m[i];
cnt[m[i]]++;
}
for (int i = 1; i... | ### Prompt
Your task is to create a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initia... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, k;
cin >> n >> k;
vector<long long> a(n), c(k);
for (long long &i : a) cin >> i;
for (long long &i : c) cin >> i;
sort(a.rbegin(), a.rend());
long long ans = 0;
long long j = 0;
long long tot = 0;
for (long long i = k - 1; i >... | ### Prompt
Please formulate a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[200000];
int c[200001];
int main() {
cin >> n >> k;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < k; i++) cin >> c[i + 1];
sort(a, a + n, greater<int>());
int ans = 0;
for (int i = k, g = 0; i >= 1; --i) {
while (g < n && a[g] ... | ### Prompt
Construct a cpp code solution to the problem outlined:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
multiset<int> a;
vector<int> c(K);
for (int i = 0; i < N; ++i) {
int x;
cin >> x;
a.insert(x);
}
for (int j = 0; j < K; ++j) {
cin >> c[j];
}
reverse(c.begin(), c.end());
vector<vector<int>> result;
... | ### Prompt
Generate a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each test... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 5;
int n, k;
int m[maxn], c[maxn];
vector<vector<int>> ans, poss;
bool check(int x) {
poss.clear();
poss.resize(x);
for (int i = 0, j = 0; i < n; i++, j = (j + 1) % x) {
if (c[m[i]] <= poss[j].size()) return false;
... | ### Prompt
Create a solution in cpp for the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each te... |
#include <bits/stdc++.h>
using namespace std;
int m[200010], c[200010], a[200010];
vector<int> v[200050];
int main() {
int n, k, i, ans = 1;
cin >> n >> k;
for (i = 1; i <= n; i++) {
cin >> m[i];
a[m[i]]++;
}
for (i = 1; i <= k; i++) cin >> c[i];
for (i = k; i; i--) {
a[i] += a[i + 1];
ans =... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;
static constexpr int INF = (int)1e9 +... | ### Prompt
Please provide a CPP coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
int m[MAXN], c[MAXN];
int main() {
int n, k;
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; ++i) {
scanf("%d", &m[i]);
}
for (int i = 1; i <= k; ++i) {
scanf("%d", &c[i]);
}... | ### Prompt
In CPP, your task is to solve the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each t... |
#include <bits/stdc++.h>
using namespace std;
void no(int ex = -1) { cout << ex << "\n"; }
void bl(bool win) {
if (win)
cout << "YES";
else
cout << "NO";
cout << "\n";
}
const int N = 2 * 10e5;
const int mod = 998244353;
vector<bool> pr;
void prime() {
int EDGE = 1000;
pr = vector<bool>(EDGE);
for (... | ### Prompt
Please formulate a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> m(n, 0);
for (auto i = 0; i < n; i++) cin >> m.at(i);
vector<int> c(k + 1, 0);
for (auto i = 1; i <= k; i++) cin >> c.at(i);
vector<int> Sum(k + 1, 0);
for (auto i = 0; i < n; i++) Sum.at(m.at(i))++;
for (a... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, k;
cin >> n >> k;
vector<long long> kol(k, 0);
for (int i = 0; i < n; i++) {
int m;
cin >> m;
m--;
kol[m]++;
}
vector<long long> suf(k, 0);
suf[k -... | ### Prompt
Please create a solution in cpp to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
signed main() {
int n, k;
cin >> n >> k;
vector<int> m(n), c(k);
for (int i = 0; i < n; i++) cin >> m[i];
for (int i = 0; i < k; i++) cin >> c[i];
sort(m.rbegin(), m.rend());
vector<vector<int>> groups;
for (int i = 0; i < n; i++) {
int x = m[i] - 1;
... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int arr = 200005;
int pow(long long int x, long long int y, long long int p) {
if (y == 0) return 1;
if (y == 1) return x;
x = x % p;
long long int ans = pow(x, y / 2, p) % p;
ans = ans * ans % p;
if (y % 2 == 0)
return ans ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each... |
#include <bits/stdc++.h>
using namespace std;
int n, k, m[222222], c[222222];
vector<int> s[222222];
int check(int x) {
for (int i = 0; i < x; i++) s[i].clear();
for (int i = 0; i < n; i++) {
if ((int)s[i % x].size() >= c[m[i]]) return 0;
s[i % x].push_back(m[i]);
}
return 1;
}
int main() {
ios_base::... | ### Prompt
Create a solution in CPP for the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each te... |
#include <bits/stdc++.h>
using namespace std;
namespace Flandre_Scarlet {
char _c;
int I() {
int x = 0;
int f = 1;
while (_c < '0' or _c > '9') f = (_c == '-') ? -1 : 1, _c = getchar();
while (_c >= '0' and _c <= '9')
x = (x << 1) + (x << 3) + (_c ^ 48), _c = getchar();
return (x = (f == 1) ? x : -x);
}
v... | ### Prompt
Construct a CPP code solution to the problem outlined:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each... |
#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
c b, e;
};
template <class c>
rge<c> range(c i, c j) {
return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
template <class c>
debug &operator<<(const c ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, each... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> a(n), c(k + 1);
for (int i = 0; i < n; ++i) cin >> a[i];
sort(a.begin(), a.end(), greater<... | ### Prompt
Please provide a cpp coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
void sol() {
long long int n, k, i;
cin >> n >> k;
vector<vector<long long int> > vc(n);
vector<long long int> a(n);
{
for (long long int _i = 0; _i < n; _i++) {
cin >> a[_i];
}
};
long long int c[k + 1];
for (i = 1; i <= k; i++) cin >> c[i];
... | ### Prompt
Develop a solution in Cpp to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int dp[200005], pt;
vector<int> res[200005];
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
v.push_back(x);
}
for (int i = 1; i <= k; i++) {
int x;
cin >> x;
dp[i] = x;
}
sort(v.rbeg... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
constexpr static int MAXN = 2e5 + 10;
int n, k;
int c[MAXN];
int cnt[MAXN];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
for (int i = 0; i < n; i++) {
int m;
cin >> m;
cnt[m]++;
}
for (int j = 0; j < k; j++) cin >> c[j... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(0);
long long i, j, k, n;
cin >> n >> k;
vector<long long> have(k), suf(k), a(n);
for (i = 0; i < n; ++i) {
cin >> j;
a[i] = j;
have[j - 1]++;
}
suf[k - 1] = have[k - 1];
for (i = k - 2; i >= 0; --i) suf[i] = ... | ### Prompt
Develop a solution in Cpp to the problem described below:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
long long c[200009];
int cnt[200009];
bool ok(int m, int k) {
long long used = 0;
for (int i = k; i > 0; i--) {
used += cnt[i];
if (used > c[i] * m) {
return false;
}
}
return true;
}
vector<int> ans[200009];
int taken[200009];
priority_queue<pair<... | ### Prompt
Please create a solution in Cpp to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
Initially, e... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int read() {
int f = 0;
char c = getchar();
while (c > '9' || c < '0') c = getchar();
while (c <= '9' && c >= '0') {
f = f * 10 + c - '0';
c = getchar();
}
return f;
}
int n, k;
int m[maxn];
int c[maxn];
set<int>::iterator tem;
i... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!
In... |
#include <bits/stdc++.h>
using namespace std;
int n, m, k, vis[100009], go[100009];
vector<int> v[100009], vv, v2[2];
void solve() {
if (vv.size() <= k) {
cout << "2\n" << vv.size() << "\n";
for (auto i : vv) cout << i << " ";
exit(0);
}
memset(vis, 0, sizeof vis);
int sz = vv.size();
for (int i =... | ### Prompt
Create a solution in Cpp for the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices such ... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + ... | ### Prompt
Develop a solution in cpp to the problem described below:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices... |
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int dep[N];
vector<int> G[N], stk, cyc, a[2];
bool dfs(int u, int fa) {
dep[u] = dep[fa] + 1;
a[dep[u] & 1].push_back(u);
stk.push_back(u);
int sz = 1e9;
for (int v : G[u]) {
if (v != fa && dep[v]) sz = min(sz, dep[u] - dep[v] + 1);
}
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set o... |
#include <bits/stdc++.h>
using namespace std;
int n, sq;
vector<vector<int> > edges;
bool inTree[100001];
int depth[100001] = {};
int anc[100001];
bool inSet[100001];
void dfs(int v, int iter) {
inTree[v] = true;
int cnt = 0;
depth[v] = iter;
for (int i = 0; i < edges[v].size(); i++) {
if (!inTree[edges[v][... | ### Prompt
Your task is to create a CPP solution to the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of ve... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7;
vector<long long> v[N];
long long vis[N], prt[N], bip[N], cs, ce;
void dfs(long long ver, long long par) {
bip[ver] = (!bip[par]);
vis[ver] = 1;
prt[ver] = par;
for (auto it : v[ver]) {
if (vis[it] == 2 || it == par) continue;
if... | ### Prompt
Develop a solution in Cpp to the problem described below:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int pwr(int a, int b) {
int ans = 1;
while (b) {
if (b & 1) ans = (ans * 1LL * a) % mod;
a = (a * 1LL * a) % mod;
b >>= 1;
}
return ans;
}
const int N = 2e5 + 5;
int u[N], v[N];
vector<pair<int, int>> g[N];
bool lol[N];
bool vis[... | ### Prompt
Your task is to create a cpp solution to the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of ve... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
vector<int> g[100010];
int visited[100010], par[100010], dep[100010];
vector<int> white, black;
vector<int> cycle;
bool dfs(int u, int color) {
visited[u] = 1;
if (color == 0)
white.push_back(u);
else
black.push_back(u);
int val =... | ### Prompt
Please create a solution in cpp to the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices... |
#include <bits/stdc++.h>
using namespace std;
void itval(istream_iterator<string> it) {}
template <typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
itval(++it, args...);
}
const long long int MOD = 998244353;
template <typename T>
inline v... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set o... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, m;
vector<vector<long long> > a(N);
long long par[N], depth[N];
bool mark[N];
long long S;
vector<long long> order;
void dfs(long long u, long long p) {
par[u] = p;
for (auto v : a[u]) {
if (par[v]) {
if (depth[u] - de... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set o... |
#include <bits/stdc++.h>
template <class T>
bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
using namespace std;
template <class E>
struct Graph {
vector<vector<E> > adj... | ### Prompt
In CPP, your task is to solve the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices such... |
#include <bits/stdc++.h>
using namespace std;
const long long INFLL = LLONG_MAX;
const int INF = INT_MAX;
const long long MAXLL = 0x3f3f3f3f3f3f3f3f;
const int MAX = 0x3f3f3f3f;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T> >;
template <class T>
void sort(vector<T>& v) {
sort(v.begin(), ... | ### Prompt
Develop a solution in cpp to the problem described below:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long double PI = acosl(-1);
const long long infl = 3e18 + 100;
const int inf = 1e8 + 100;
const int nmax = 1e5 + 5;
const int MAXLG = log2(nmax) + 1;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
int n, rutn;
int par[nmax], le... | ### Prompt
Generate a CPP solution to the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices such th... |
#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e5 + 5;
vector<int> adj[mxn];
int level[mxn];
int vis[mxn];
int n, m;
int bad[mxn];
int par[mxn];
void dfs(int node) {
vis[node] = 1;
for (auto& u : adj[node]) {
if (!vis[u]) {
par[u] = node;
level[u] = level[node] + 1;
dfs(u);
... | ### Prompt
Create a solution in cpp for the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices such ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
scanf("%d%d", &n, &m);
if (n == 1) return cout << 1 << '\n' << 1, 0;
int sq = ceil(sqrt(n));
vector<unordered_map<int, bool>> mat(n);
vector<vector<int>> adj(n);
vector<int> deg(n);
for (int i = 0, u, v; i < m; i++) {
scanf("%d%d",... | ### Prompt
In cpp, your task is to solve the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices such... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <typename T>
T binpow(T a, T b, T modi) {
T res = 1;
while (b) {
if (b & 1) {
res = (res * a) % modi;
}
b /= 2;
(a *= a) %= modi;
}
return res;
}
template <typename T>
T binpow(T a, T b) {
T res = 1;
... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set o... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m, k;
int par[N], dep[N], tag[N];
vector<int> g[N], ans2;
int flag;
void dfs(int u, int fa) {
if (flag) return;
dep[u] = dep[par[u] = fa] + 1;
for (auto &v : g[u])
if (v != fa) {
if (!dep[v])
dfs(v, u);
else {
... | ### Prompt
In Cpp, your task is to solve the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices such... |
#include <bits/stdc++.h>
using namespace std;
const long long M = 998244353, maxn = 2e5 + 500;
long long int ans, q, k, d, n, m, x, y, h[maxn], par[maxn], k1, k2;
bool flag = false;
long long int mark[maxn];
std::vector<long long int> adj[maxn];
void dfs(long long int v) {
mark[v] = true;
for (long long int i : adj... | ### Prompt
Your task is to create a cpp solution to the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of ve... |
#include <bits/stdc++.h>
using namespace std;
void dfs(int v, int c, vector<vector<int>>& g, vector<bool>& used,
vector<vector<int>>& color) {
if (!used[v]) {
used[v] = true;
color[c].push_back(v);
for (auto u : g[v]) dfs(u, (c + 1) % 2, g, used, color);
}
}
int cycle_vertex(int v, vector<vecto... | ### Prompt
Please formulate a Cpp solution to the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices... |
#include <bits/stdc++.h>
using namespace std;
int n, m, h[100005], cnt, deep[100005], prt[100005], B, sta[100005], tot, num;
bool flag = 0;
bool vis[100005], vst[100005];
vector<int> ans;
struct Edge {
int to, next;
} w[400005];
void add(int x, int y) {
w[++cnt] = (Edge){y, h[x]};
h[x] = cnt;
}
void dfs(int x, in... | ### Prompt
Construct a CPP code solution to the problem outlined:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices su... |
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
while (a != 0 && b != 0) {
if (a > b)
a %= b;
else
b %= a;
}
return max(a, b);
}
void boost() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, m, k;
vector<vector<int>> vec(100005);
vector<in... | ### Prompt
Develop a solution in cpp to the problem described below:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int gi() {
int x = 0, o = 1;
char ch = getchar();
while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
if (ch == '-') o = -1, ch = getchar();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
return x * o;
}
int... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set o... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
int n, m, k, st, vis[N];
set<int> sOdd, sEven;
vector<int> g[N], ansOne, ansTwo, vOdd, vEven;
void dfs(int u, int p, int cnt) {
vis[u] = cnt;
for (auto v : g[u])... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set o... |
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 100005;
int n, m, k;
vector<int> a[N];
vector<int> v[2];
void dfs0(int x, int p, int z) {
v[z].push_back(x);
for (int i = 0; i < a[x].size(); ++i) {
int h = a[x][i]... | ### Prompt
Create a solution in cpp for the following problem:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices such ... |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e5 + 10;
long long rd() {
long long _;
scanf("%lld", &_);
return _;
}
long long n, m, sq, st, ed, path[maxn], depth[maxn];
vector<long long> dep2node[maxn], edge[maxn];
void dfs(long long u, long long dep) {
depth[u] = dep;
for (auto &v : e... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Given a connected undirected graph with n vertices and an integer k, you have to either:
* either find an independent set that has exactly ⌈k/2⌉ vertices.
* or find a simple cycle of length at most k.
An independent set is a set of vertices su... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.