problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k ⌀ | fixed_code stringlengths 12 526k ⌀ | labels listlengths 0 15 ⌀ | buggy_submission_id int64 1 1.54M ⌀ | fixed_submission_id int64 2 1.54M ⌀ | user_id stringlengths 10 10 ⌀ | language stringclasses 9 values |
|---|---|---|---|---|---|---|---|
p02973 | #include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <vector>
using namespace std;
using ll = long long;
ll solve(vector<ll> &va, vector<ll> &memo) {
for (int i = 0; i < va.size(); ++i) {
*lower_bound(memo.begin(), memo.end(), va[i]) = va[i];
}
auto r_it = lower_bound(memo.begin(), memo.end(), numeric_limits<ll>::max());
return distance(memo.begin(), r_it);
}
int main(int argc, const char *argv[]) {
int n;
cin >> n;
vector<ll> va(n);
for (int i = 0; i < n; ++i) {
cin >> va[i];
}
reverse(va.begin(), va.end());
vector<ll> memo(n + 1, numeric_limits<ll>::max());
cout << solve(va, memo) << '\n';
return 0;
} | #include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <vector>
using namespace std;
using ll = long long;
ll solve(vector<ll> &va, vector<ll> &memo) {
for (int i = 0; i < va.size(); ++i) {
*upper_bound(memo.begin(), memo.end(), va[i]) = va[i];
}
auto r_it = lower_bound(memo.begin(), memo.end(), numeric_limits<ll>::max());
return distance(memo.begin(), r_it);
}
int main(int argc, const char *argv[]) {
int n;
cin >> n;
vector<ll> va(n);
for (int i = 0; i < n; ++i) {
cin >> va[i];
}
reverse(va.begin(), va.end());
vector<ll> memo(n + 1, numeric_limits<ll>::max());
cout << solve(va, memo) << '\n';
return 0;
} | [
"assignment.variable.change",
"identifier.change",
"call.function.change"
] | 781,262 | 781,263 | u289545075 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
long long MOD = 1000000000 + 7;
int main() {
cout << setprecision(10);
int N;
cin >> N;
deque<ll> q;
for (int i = 0; i < N; i++) {
ll tmp;
cin >> tmp;
auto itr = lower_bound(q.begin(), q.end(), tmp);
int index = distance(itr, q.begin());
if (index == 0) {
q.push_front(tmp);
} else {
q[index - 1] = tmp;
}
}
cout << q.size() << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
long long MOD = 1000000000 + 7;
int main() {
cout << setprecision(10);
int N;
cin >> N;
deque<ll> q;
for (int i = 0; i < N; i++) {
ll tmp;
cin >> tmp;
auto itr = lower_bound(q.begin(), q.end(), tmp);
int index = distance(q.begin(), itr);
if (index == 0) {
q.push_front(tmp);
} else {
q[index - 1] = tmp;
}
}
cout << q.size() << endl;
}
| [
"call.arguments.change",
"call.arguments.add"
] | 781,264 | 781,265 | u190875453 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
long long MOD = 1000000000 + 7;
int main() {
cout << setprecision(10);
int N;
cin >> N;
deque<int> q;
for (int i = 0; i < N; i++) {
int tmp;
cin >> tmp;
auto itr = lower_bound(q.begin(), q.end(), tmp);
int index = distance(itr, q.begin());
if (index == 0) {
q.push_front(tmp);
} else {
q[index - 1] = tmp;
}
}
cout << q.size() << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
long long MOD = 1000000000 + 7;
int main() {
cout << setprecision(10);
int N;
cin >> N;
deque<ll> q;
for (int i = 0; i < N; i++) {
ll tmp;
cin >> tmp;
auto itr = lower_bound(q.begin(), q.end(), tmp);
int index = distance(q.begin(), itr);
if (index == 0) {
q.push_front(tmp);
} else {
q[index - 1] = tmp;
}
}
cout << q.size() << endl;
}
| [
"variable_declaration.type.change",
"call.arguments.change",
"call.arguments.add"
] | 781,266 | 781,265 | u190875453 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
multiset<int> act;
int t;
for (int i = 0; i < N; i++) {
cin >> t;
if (!act.size() || *act.begin() >= t)
act.insert(t);
else {
auto p = act.upper_bound(t);
p--;
act.erase(p);
act.insert(t);
}
}
cout << act.size() << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
multiset<int> act;
int t;
for (int i = 0; i < N; i++) {
cin >> t;
if (!act.size() || *act.begin() >= t)
act.insert(t);
else {
auto p = act.lower_bound(t);
p--;
act.erase(p);
act.insert(t);
}
}
cout << act.size() << endl;
} | [
"call.function.change"
] | 781,267 | 781,268 | u015490689 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;
int main() {
int n;
cin >> n;
vi a(n);
rep(i, n) cin >> a[i];
multiset<int> cc;
rep(i, n) {
auto k = cc.lower_bound(a[i]);
if (k != cc.begin()) {
k--;
cc.erase(*k);
}
cc.insert(a[i]);
}
cout << cc.size() << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;
int main() {
int n;
cin >> n;
vi a(n);
rep(i, n) cin >> a[i];
multiset<int> cc;
rep(i, n) {
auto k = cc.lower_bound(a[i]);
if (k != cc.begin()) {
k--;
cc.erase(k);
}
cc.insert(a[i]);
}
cout << cc.size() << endl;
} | [
"call.arguments.change"
] | 781,269 | 781,270 | u595084562 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, x, n) for (int i = x; i < n; i++)
int main() {
int N;
cin >> N;
multiset<long long> s;
long long a;
rep(i, N) {
cin >> a;
s.insert(a);
set<long long>::iterator ite;
;
ite = s.find(a);
while (ite != s.begin()) {
ite--;
if (*ite < a) {
s.erase(*ite);
break;
}
}
}
cout << s.size() << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, x, n) for (int i = x; i < n; i++)
int main() {
int N;
cin >> N;
multiset<long long> s;
long long a;
rep(i, N) {
cin >> a;
s.insert(a);
multiset<long long>::iterator ite;
;
ite = s.find(a);
while (ite != s.begin()) {
ite--;
if (*ite < a) {
s.erase(ite);
break;
}
}
}
cout << s.size() << endl;
} | [
"call.arguments.change"
] | 781,271 | 781,272 | u879436400 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, x, n) for (int i = x; i < n; i++)
int main() {
int N;
cin >> N;
multiset<long long> s;
long long a;
rep(i, N) {
cin >> a;
s.insert(a);
multiset<long long>::iterator ite;
;
ite = s.find(a);
while (ite != s.begin()) {
ite--;
if (*ite < a) {
s.erase(*ite);
break;
}
}
}
cout << s.size() << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, x, n) for (int i = x; i < n; i++)
int main() {
int N;
cin >> N;
multiset<long long> s;
long long a;
rep(i, N) {
cin >> a;
s.insert(a);
multiset<long long>::iterator ite;
;
ite = s.find(a);
while (ite != s.begin()) {
ite--;
if (*ite < a) {
s.erase(ite);
break;
}
}
}
cout << s.size() << endl;
} | [
"call.arguments.change"
] | 781,273 | 781,272 | u879436400 | cpp |
p02973 | #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
#define dump(x) cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template <typename T> void print(const vector<T> &x) {
int n = x.size();
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x) {
int n = x.size();
rep(i, n) {
rep(j, x[i].size()) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <typename T> void print(const vector<T> &x, int n) {
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x, int n, int m) {
rep(i, n) {
rep(j, m) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
void input_init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int main(int argc, char const *argv[]) {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
set<int> st;
rep(i, n) {
if (st.empty()) {
st.insert(a[i]);
} else {
auto itr = st.lower_bound(a[i]);
if (itr == st.begin())
st.insert(a[i]);
else {
--itr;
st.erase(itr);
st.insert(a[i]);
}
}
}
cout << st.size() << '\n';
return 0;
} | #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
#define dump(x) cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template <typename T> void print(const vector<T> &x) {
int n = x.size();
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x) {
int n = x.size();
rep(i, n) {
rep(j, x[i].size()) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <typename T> void print(const vector<T> &x, int n) {
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x, int n, int m) {
rep(i, n) {
rep(j, m) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
void input_init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int main(int argc, char const *argv[]) {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
multiset<int> st;
rep(i, n) {
if (st.empty()) {
st.insert(a[i]);
} else {
auto itr = st.lower_bound(a[i]);
if (itr == st.begin())
st.insert(a[i]);
else {
--itr;
st.erase(itr);
st.insert(a[i]);
}
}
}
cout << st.size() << '\n';
return 0;
} | [
"variable_declaration.type.change"
] | 781,274 | 781,275 | u102602414 | cpp |
p02973 | #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
#define dump(x) cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template <typename T> void print(const vector<T> &x) {
int n = x.size();
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x) {
int n = x.size();
rep(i, n) {
rep(j, x[i].size()) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <typename T> void print(const vector<T> &x, int n) {
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x, int n, int m) {
rep(i, n) {
rep(j, m) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
void input_init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int main(int argc, char const *argv[]) {
int n;
cin >> n;
vector<ll> a(n);
rep(i, n) cin >> a[i];
multiset<ll> st;
rep(i, n) {
if (st.empty())
st.insert(a[i]);
else {
auto itr = st.upper_bound(a[i]);
if (itr == st.begin())
st.insert(a[i]);
else {
--itr;
st.erase(itr);
st.insert(a[i]);
}
}
}
cout << st.size() << '\n';
return 0;
} | #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
#define dump(x) cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template <typename T> void print(const vector<T> &x) {
int n = x.size();
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x) {
int n = x.size();
rep(i, n) {
rep(j, x[i].size()) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <typename T> void print(const vector<T> &x, int n) {
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x, int n, int m) {
rep(i, n) {
rep(j, m) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
void input_init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int main(int argc, char const *argv[]) {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
multiset<int> st;
rep(i, n) {
if (st.empty()) {
st.insert(a[i]);
} else {
auto itr = st.lower_bound(a[i]);
if (itr == st.begin())
st.insert(a[i]);
else {
--itr;
st.erase(itr);
st.insert(a[i]);
}
}
}
cout << st.size() << '\n';
return 0;
} | [
"call.function.change"
] | 781,276 | 781,275 | u102602414 | cpp |
p02973 | #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
#define dump(x) cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template <typename T> void print(const vector<T> &x) {
int n = x.size();
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x) {
int n = x.size();
rep(i, n) {
rep(j, x[i].size()) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <typename T> void print(const vector<T> &x, int n) {
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x, int n, int m) {
rep(i, n) {
rep(j, m) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
void input_init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int main(int argc, char const *argv[]) {
int n;
cin >> n;
vector<ll> a(n);
rep(i, n) cin >> a[i];
multiset<ll> st;
rep(i, n) {
if (st.empty())
st.insert(a[i]);
else {
auto itr = st.upper_bound(a[i]);
if (itr == st.begin())
st.insert(a[i]);
else {
--itr;
st.erase(itr);
st.insert(a[i]);
}
}
}
cout << st.size() << '\n';
return 0;
} | #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
#define dump(x) cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template <typename T> void print(const vector<T> &x) {
int n = x.size();
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x) {
int n = x.size();
rep(i, n) {
rep(j, x[i].size()) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <typename T> void print(const vector<T> &x, int n) {
rep(i, n) {
cout << x[i];
if (i != n - 1)
cout << " ";
else
cout << endl;
}
}
template <typename T> void print(const vector<vector<T>> &x, int n, int m) {
rep(i, n) {
rep(j, m) { cout << x[i][j] << " "; }
cout << endl;
}
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
void input_init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int main(int argc, char const *argv[]) {
int n;
cin >> n;
vector<ll> a(n);
rep(i, n) cin >> a[i];
multiset<ll> st;
rep(i, n) {
if (st.empty())
st.insert(a[i]);
else {
auto itr = st.lower_bound(a[i]);
if (itr == st.begin())
st.insert(a[i]);
else {
--itr;
st.erase(itr);
st.insert(a[i]);
}
}
}
cout << st.size() << '\n';
return 0;
} | [
"call.function.change"
] | 781,276 | 781,277 | u102602414 | cpp |
p02973 | #include <memory.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define mod 1000000007
int main() {
int n;
cin >> n;
int a[100000];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> v;
for (int i = 0; i < n; i++) {
if (v.size() == 0 || v[v.size() - 1] >= a[i]) {
v.push_back(a[i]);
} else {
for (int i = 0; i < v.size(); i++) {
if (v[i] < a[i]) {
v[i] = a[i];
break;
}
}
}
}
cout << v.size() << endl;
} | #include <memory.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define mod 1000000007
int main() {
int n;
cin >> n;
int a[100000];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> v;
for (int i = 0; i < n; i++) {
if (v.size() == 0 || v[v.size() - 1] >= a[i]) {
v.push_back(a[i]);
} else {
for (int j = 0; j < v.size(); j++) {
if (v[j] < a[i]) {
v[j] = a[i];
break;
}
}
}
}
cout << v.size() << endl;
} | [
"variable_declaration.name.change",
"identifier.change",
"control_flow.loop.for.initializer.change",
"control_flow.branch.if.condition.change",
"variable_access.subscript.index.change",
"assignment.variable.change"
] | 781,278 | 781,279 | u261965335 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
int N;
int main() {
cin >> N;
int a[N];
for (int i = 0; i < N; i++) {
cin >> a[i];
}
vector<int> b;
b.push_back(a[N - 1]);
for (int i = 1; i < N; i++) {
if (a[N - 1 - i] >= b[b.size() - 1])
b.push_back(a[N - 1 - i]);
else {
auto c = lower_bound(b.begin(), b.end(), a[N - 1 - i]);
b[c - b.begin()] = a[N - 1 - i];
}
}
cout << b.size() << endl;
} | #include <bits/stdc++.h>
using namespace std;
int N;
int main() {
cin >> N;
int a[N];
for (int i = 0; i < N; i++) {
cin >> a[i];
}
vector<int> b;
b.push_back(a[N - 1]);
for (int i = 1; i < N; i++) {
if (a[N - 1 - i] >= b[b.size() - 1])
b.push_back(a[N - 1 - i]);
else {
auto c = upper_bound(b.begin(), b.end(), a[N - 1 - i]);
b[c - b.begin()] = a[N - 1 - i];
}
}
cout << b.size() << endl;
} | [
"identifier.change",
"call.function.change"
] | 781,280 | 781,281 | u315542000 | cpp |
p02973 | #ifdef LOCAL
#define _GLIBCXX_DEBUG
#define __clock__
#else
#pragma GCC optimize("Ofast")
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;
// tourist set
template <typename A, typename B> string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
bool first = true;
string res = "{";
for (int i = 0; i < static_cast<int>(v.size()); i++) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(v[i]);
}
res += "}";
return res;
}
template <size_t N> string to_string(bitset<N> v) {
string res = "";
for (size_t i = 0; i < N; i++) {
res += static_cast<char>('0' + v[i]);
}
return res;
}
template <typename A> string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
template <typename A, typename B> string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end
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 (b < a) {
a = b;
return 1;
}
return 0;
}
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout << (s) << '\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair
#define p_yes() p("Yes")
#define p_no() p("No")
ll SUM(VI &V) { return accumulate(ALL(V), 0LL); }
ll MIN(VI &V) { return *min_element(ALL(V)); }
ll MAX(VI &V) { return *max_element(ALL(V)); }
void print_vector(VI &V) {
ll n = V.size();
rep(i, n) {
if (i)
cout << ' ';
cout << V[i];
}
cout << endl;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
// long double
using ld = long double;
#define EPS (1e-14)
#define equals(a, b) (fabs((a) - (b)) < EPS)
void no() {
p_no();
exit(0);
}
void yes() {
p_yes();
exit(0);
}
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);
ll LIS2(VI &A) {
ll N = A.size();
VI V;
V.push_back(A[0]);
FOR(i, 1, N) {
ll a = A[i];
if (V.back() <= a) {
// if(V.back()<a){
V.push_back(a);
} else {
auto it = lower_bound(ALL(V), a);
*it = a;
}
}
return V.size();
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// input
ll N;
cin >> N;
VI A(N);
rep(i, N) cin >> A[i];
reverse(ALL(A));
ll ans = LIS2(A);
p(ans);
return 0;
} | #ifdef LOCAL
#define _GLIBCXX_DEBUG
#define __clock__
#else
#pragma GCC optimize("Ofast")
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;
// tourist set
template <typename A, typename B> string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
bool first = true;
string res = "{";
for (int i = 0; i < static_cast<int>(v.size()); i++) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(v[i]);
}
res += "}";
return res;
}
template <size_t N> string to_string(bitset<N> v) {
string res = "";
for (size_t i = 0; i < N; i++) {
res += static_cast<char>('0' + v[i]);
}
return res;
}
template <typename A> string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
template <typename A, typename B> string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end
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 (b < a) {
a = b;
return 1;
}
return 0;
}
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout << (s) << '\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair
#define p_yes() p("Yes")
#define p_no() p("No")
ll SUM(VI &V) { return accumulate(ALL(V), 0LL); }
ll MIN(VI &V) { return *min_element(ALL(V)); }
ll MAX(VI &V) { return *max_element(ALL(V)); }
void print_vector(VI &V) {
ll n = V.size();
rep(i, n) {
if (i)
cout << ' ';
cout << V[i];
}
cout << endl;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
// long double
using ld = long double;
#define EPS (1e-14)
#define equals(a, b) (fabs((a) - (b)) < EPS)
void no() {
p_no();
exit(0);
}
void yes() {
p_yes();
exit(0);
}
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);
ll LIS2(VI &A) {
ll N = A.size();
VI V;
V.push_back(A[0]);
FOR(i, 1, N) {
ll a = A[i];
if (V.back() <= a) {
// if(V.back()<a){
V.push_back(a);
} else {
// auto it = lower_bound(ALL(V), a);
auto it = upper_bound(ALL(V), a);
*it = a;
}
}
debug(V);
return V.size();
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// input
ll N;
cin >> N;
VI A(N);
rep(i, N) cin >> A[i];
reverse(ALL(A));
ll ans = LIS2(A);
p(ans);
return 0;
} | [
"identifier.change",
"call.function.change",
"call.add"
] | 781,282 | 781,283 | u432688695 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
ll A[100005];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
REP(i, N) { cin >> A[i]; }
ll ans = 0;
std::set<ll> s;
s.insert(-1);
for (ll i = N - 1; i >= 0; --i) {
auto it = s.upper_bound(A[i]);
if (it == s.end()) {
ans++;
s.insert(A[i]);
continue;
}
s.erase(it);
s.insert(A[i]);
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
ll A[100005];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
REP(i, N) { cin >> A[i]; }
ll ans = 0;
std::multiset<ll> s;
s.insert(-1);
for (ll i = N - 1; i >= 0; --i) {
auto it = s.upper_bound(A[i]);
if (it == s.end()) {
ans++;
s.insert(A[i]);
continue;
}
s.erase(it);
s.insert(A[i]);
}
cout << ans << endl;
return 0;
} | [] | 781,286 | 781,287 | u340980616 | cpp |
p02973 | #include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> ans;
ans.push_back(a[0]);
for (int i = 1; i < n; ++i) {
if (a[i] <= ans.back()) {
ans.push_back(a[i]);
continue;
}
int left = -1, right = ans.size();
while (1) {
ll mid = ((1LL) * left + (1LL) * right) / 2;
if (a[i] < ans[mid])
left = mid;
else
right = mid;
if (right - left == 1) {
ans[right] = a[i];
break;
}
}
// rep(i,ans.size())cout<<ans[i]<<" ";cout<<endl;
}
cout << ans.size() << endl;
return 0;
} | #include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> ans;
ans.push_back(a[0]);
for (int i = 1; i < n; ++i) {
if (a[i] <= ans.back()) {
ans.push_back(a[i]);
continue;
}
int left = -1, right = ans.size();
while (1) {
ll mid = ((1LL) * left + (1LL) * right) / 2;
if (a[i] <= ans[mid])
left = mid;
else
right = mid;
if (right - left == 1) {
ans[right] = a[i];
break;
}
}
// rep(i,ans.size())cout<<ans[i]<<" ";cout<<endl;
}
cout << ans.size() << endl;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 781,288 | 781,289 | u184929210 | cpp |
p02973 | #include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> ans;
ans.push_back(a[0]);
for (int i = 1; i < n; ++i) {
int left = -1, right = ans.size();
while (1) {
ll mid = ((1LL) * left + (1LL) * right) / 2;
if (a[i] < ans[mid])
left = mid;
else
right = mid;
if (right - left == 1) {
if (right == ans.size()) {
ans.push_back(a[i]);
} else {
ans[right] = a[i];
}
break;
}
}
// rep(i,ans.size())cout<<ans[i]<<" ";cout<<endl;
}
cout << ans.size() << endl;
return 0;
} | #include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> ans;
ans.push_back(a[0]);
for (int i = 1; i < n; ++i) {
int left = -1, right = ans.size();
while (1) {
ll mid = ((1LL) * left + (1LL) * right) / 2;
if (a[i] <= ans[mid])
left = mid;
else
right = mid;
if (right - left == 1) {
if (right == ans.size()) {
ans.push_back(a[i]);
} else {
ans[right] = a[i];
}
break;
}
}
// rep(i,ans.size())cout<<ans[i]<<" ";cout<<endl;
}
cout << ans.size() << endl;
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 781,290 | 781,291 | u184929210 | cpp |
p02973 | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author champon
*/
#include <fstream>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, s, e) for (ll i = s; i >= e; i--)
#define reps(i, s, e) for (ll i = s; i <= e; i++)
#define inf 1e18
#define all(v) v.begin(), v.end()
#define ceill(a, b) (a + b - 1) / b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b) { cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <typename T> inline bool chmax(T &a, T b) {
if (a < b)
a = b;
return a < b;
}
template <typename T> inline bool chmin(T &a, T b) {
if (b < a)
a = b;
return b < a;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
template <typename T> void vdeb(T v) {
cout << "#vector set debug" << endl;
for (auto vv : v)
cout << vv << " ";
cout << endl;
}
template <typename T1, typename T2> void adeb(T1 arr[], T2 n) {
cout << "#adebug" << endl;
for (int i = 0; i <= n; i++)
cout << arr[i] << " ";
cout << endl;
}
template <typename T1> void mdeb(T1 mp) {
cout << "#map pair debug" << endl;
for (auto const &m : mp)
cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
class ESequenceDecomposing {
public:
void solve(std::istream &in, std::ostream &out) {
int n;
in >> n;
vector<ll> a(n, 0);
rep(i, n) { in >> a[i]; }
vector<ll> head;
rep(i, n) {
int ind = distance(head.begin(), lower_bound(all(head), a[i]));
if (ind == 0) {
head.insert(head.begin(), a[i]);
} else {
head[ind] = a[i];
}
}
out << head.size() << endl;
}
};
int main() {
ESequenceDecomposing solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author champon
*/
#include <fstream>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, s, e) for (ll i = s; i >= e; i--)
#define reps(i, s, e) for (ll i = s; i <= e; i++)
#define inf 1e18
#define all(v) v.begin(), v.end()
#define ceill(a, b) (a + b - 1) / b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b) { cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <typename T> inline bool chmax(T &a, T b) {
if (a < b)
a = b;
return a < b;
}
template <typename T> inline bool chmin(T &a, T b) {
if (b < a)
a = b;
return b < a;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
template <typename T> void vdeb(T v) {
cout << "#vector set debug" << endl;
for (auto vv : v)
cout << vv << " ";
cout << endl;
}
template <typename T1, typename T2> void adeb(T1 arr[], T2 n) {
cout << "#adebug" << endl;
for (int i = 0; i <= n; i++)
cout << arr[i] << " ";
cout << endl;
}
template <typename T1> void mdeb(T1 mp) {
cout << "#map pair debug" << endl;
for (auto const &m : mp)
cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
class ESequenceDecomposing {
public:
void solve(std::istream &in, std::ostream &out) {
int n;
in >> n;
vector<ll> a(n, 0);
rep(i, n) { in >> a[i]; }
vector<ll> head;
rep(i, n) {
int ind = distance(head.begin(), lower_bound(all(head), a[i]));
if (ind == 0) {
head.insert(head.begin(), a[i]);
} else {
head[ind - 1] = a[i];
}
}
out << head.size() << endl;
}
};
int main() {
ESequenceDecomposing solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| [
"assignment.change"
] | 781,292 | 781,293 | u026620445 | cpp |
p02973 | #define DEBUG 1
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using tll = tuple<ll, ll, ll>;
using vtll = vector<tll>;
using vvtll = vector<vtll>;
#define all(v) (v).begin(), (v).end()
#define for1(i, n) for (ll i = 0; i < (n); i++)
#define for2(i, m, n) for (ll i = (m); i < (n); i++)
#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))
#define rfor2(i, m, n) for (ll i = (m); i > (n); i--)
#define rfor3(i, m, n, d) for (ll i = (m); i > (n); i += (d))
#define PI 3.1415926535897932384626433832795028841971693993751L
#define INF 1111111111111111111LL
#define print(...) print_1(__VA_ARGS__)
#define in(...) in_1(__VA_ARGS__)
#if DEBUG
#define dump(...) dump_1(#__VA_ARGS__, __VA_ARGS__)
#define dumpa(...) dumpa_1(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#define dumpa(...)
#endif
template <typename Head> void dump_1(const char *str, Head &&h) {
cerr << str << ": " << h << '\n';
}
template <typename Head, typename... Tail>
void dump_1(const char *str, Head &&h, Tail &&...t) {
while (*str != ',') {
cerr << *str++;
}
cerr << ": " << h << ' ';
dump_1(str + 1, t...);
}
template <typename T>
void dumpa_1(const char *str, const T v[], const ll size) {
while (*str != ',') {
cerr << *str++;
}
cerr << ": ";
for1(i, size) {
if (i != 0) {
cerr << ' ';
}
cerr << v[i];
}
cerr << '\n';
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &v) {
os << v.first << ' ' << v.second;
return os;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &os, const tuple<T1, T2, T3> &v) {
os << get<0>(v) << ' ' << get<1>(v) << ' ' << get<2>(v);
return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &v) {
os << '{';
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ", ";
}
os << it->first << ':' << it->second;
}
os << '}';
return os;
}
ll divup(ll nume, ll deno) {
assert(nume >= 0);
assert(deno > 0);
return (nume + deno - 1) / deno;
}
void Yes(void) { cout << "Yes\n"; }
void No(void) { cout << "No\n"; }
void YES(void) { cout << "YES\n"; }
void NO(void) { cout << "NO\n"; }
template <typename T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T> void vin(vector<T> &v) {
ll len = v.size();
for1(i, len) { cin >> v[i]; }
}
template <typename Head> void in_1(Head &h) { cin >> h; }
template <typename Head, typename... Tail> void in_1(Head &h, Tail &...t) {
cin >> h;
in_1(t...);
}
template <typename Head> void print_1(Head &&h) { cout << h << '\n'; }
template <typename Head, typename... Tail> void print_1(Head &&h, Tail &&...t) {
cout << h << ' ';
print_1(t...);
}
//---------------------------------------------------------
const ll mod = 1000000007LL; // 10**9 + 7
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
friend ostream &operator<<(ostream &os, const mint &v) {
os << v.x;
return os;
}
};
//---------------------------------------------------------
struct mintcomb {
vector<mint> fact, ifact;
mintcomb(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) {
fact[i] = fact[i - 1] * i;
}
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) {
ifact[i - 1] = ifact[i] * i;
}
}
mint permutation(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[n - k];
}
mint combination(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
//---------------------------------------------------------
void solve() {
ll N;
in(N);
vll A(N);
vin(A);
multiset<ll> col;
for1(i, N) {
if (col.size() == 0 || A[i] <= *col.begin()) {
col.insert(A[i]);
continue;
}
auto it = col.lower_bound(A[i]);
it--;
col.erase(*it);
col.insert(A[i]);
}
print(col.size());
}
//---------------------------------------------------------
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(16);
cerr << fixed << setprecision(16);
solve();
}
| #define DEBUG 1
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using tll = tuple<ll, ll, ll>;
using vtll = vector<tll>;
using vvtll = vector<vtll>;
#define all(v) (v).begin(), (v).end()
#define for1(i, n) for (ll i = 0; i < (n); i++)
#define for2(i, m, n) for (ll i = (m); i < (n); i++)
#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))
#define rfor2(i, m, n) for (ll i = (m); i > (n); i--)
#define rfor3(i, m, n, d) for (ll i = (m); i > (n); i += (d))
#define PI 3.1415926535897932384626433832795028841971693993751L
#define INF 1111111111111111111LL
#define print(...) print_1(__VA_ARGS__)
#define in(...) in_1(__VA_ARGS__)
#if DEBUG
#define dump(...) dump_1(#__VA_ARGS__, __VA_ARGS__)
#define dumpa(...) dumpa_1(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#define dumpa(...)
#endif
template <typename Head> void dump_1(const char *str, Head &&h) {
cerr << str << ": " << h << '\n';
}
template <typename Head, typename... Tail>
void dump_1(const char *str, Head &&h, Tail &&...t) {
while (*str != ',') {
cerr << *str++;
}
cerr << ": " << h << ' ';
dump_1(str + 1, t...);
}
template <typename T>
void dumpa_1(const char *str, const T v[], const ll size) {
while (*str != ',') {
cerr << *str++;
}
cerr << ": ";
for1(i, size) {
if (i != 0) {
cerr << ' ';
}
cerr << v[i];
}
cerr << '\n';
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &v) {
os << v.first << ' ' << v.second;
return os;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &os, const tuple<T1, T2, T3> &v) {
os << get<0>(v) << ' ' << get<1>(v) << ' ' << get<2>(v);
return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &v) {
os << '{';
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ", ";
}
os << it->first << ':' << it->second;
}
os << '}';
return os;
}
ll divup(ll nume, ll deno) {
assert(nume >= 0);
assert(deno > 0);
return (nume + deno - 1) / deno;
}
void Yes(void) { cout << "Yes\n"; }
void No(void) { cout << "No\n"; }
void YES(void) { cout << "YES\n"; }
void NO(void) { cout << "NO\n"; }
template <typename T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T> void vin(vector<T> &v) {
ll len = v.size();
for1(i, len) { cin >> v[i]; }
}
template <typename Head> void in_1(Head &h) { cin >> h; }
template <typename Head, typename... Tail> void in_1(Head &h, Tail &...t) {
cin >> h;
in_1(t...);
}
template <typename Head> void print_1(Head &&h) { cout << h << '\n'; }
template <typename Head, typename... Tail> void print_1(Head &&h, Tail &&...t) {
cout << h << ' ';
print_1(t...);
}
//---------------------------------------------------------
const ll mod = 1000000007LL; // 10**9 + 7
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
friend ostream &operator<<(ostream &os, const mint &v) {
os << v.x;
return os;
}
};
//---------------------------------------------------------
struct mintcomb {
vector<mint> fact, ifact;
mintcomb(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) {
fact[i] = fact[i - 1] * i;
}
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) {
ifact[i - 1] = ifact[i] * i;
}
}
mint permutation(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[n - k];
}
mint combination(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
//---------------------------------------------------------
void solve() {
ll N;
in(N);
vll A(N);
vin(A);
multiset<ll> col;
for1(i, N) {
if (col.size() == 0 || A[i] <= *col.begin()) {
col.insert(A[i]);
continue;
}
auto it = col.lower_bound(A[i]);
it--;
col.erase(it);
col.insert(A[i]);
}
print(col.size());
}
//---------------------------------------------------------
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(16);
cerr << fixed << setprecision(16);
solve();
}
| [
"call.arguments.change"
] | 781,294 | 781,295 | u426683236 | cpp |
p02973 | #define DEBUG 1
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using tll = tuple<ll, ll, ll>;
using vtll = vector<tll>;
using vvtll = vector<vtll>;
#define all(v) (v).begin(), (v).end()
#define for1(i, n) for (ll i = 0; i < (n); i++)
#define for2(i, m, n) for (ll i = (m); i < (n); i++)
#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))
#define rfor2(i, m, n) for (ll i = (m); i > (n); i--)
#define rfor3(i, m, n, d) for (ll i = (m); i > (n); i += (d))
#define PI 3.1415926535897932384626433832795028841971693993751L
#define INF 1111111111111111111LL
#define print(...) print_1(__VA_ARGS__)
#define in(...) in_1(__VA_ARGS__)
#if DEBUG
#define dump(...) dump_1(#__VA_ARGS__, __VA_ARGS__)
#define dumpa(...) dumpa_1(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#define dumpa(...)
#endif
template <typename Head> void dump_1(const char *str, Head &&h) {
cerr << str << ": " << h << '\n';
}
template <typename Head, typename... Tail>
void dump_1(const char *str, Head &&h, Tail &&...t) {
while (*str != ',') {
cerr << *str++;
}
cerr << ": " << h << ' ';
dump_1(str + 1, t...);
}
template <typename T>
void dumpa_1(const char *str, const T v[], const ll size) {
while (*str != ',') {
cerr << *str++;
}
cerr << ": ";
for1(i, size) {
if (i != 0) {
cerr << ' ';
}
cerr << v[i];
}
cerr << '\n';
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &v) {
os << v.first << ' ' << v.second;
return os;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &os, const tuple<T1, T2, T3> &v) {
os << get<0>(v) << ' ' << get<1>(v) << ' ' << get<2>(v);
return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &v) {
os << '{';
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ", ";
}
os << it->first << ':' << it->second;
}
os << '}';
return os;
}
ll divup(ll nume, ll deno) {
assert(nume >= 0);
assert(deno > 0);
return (nume + deno - 1) / deno;
}
void Yes(void) { cout << "Yes\n"; }
void No(void) { cout << "No\n"; }
void YES(void) { cout << "YES\n"; }
void NO(void) { cout << "NO\n"; }
template <typename T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T> void vin(vector<T> &v) {
ll len = v.size();
for1(i, len) { cin >> v[i]; }
}
template <typename Head> void in_1(Head &h) { cin >> h; }
template <typename Head, typename... Tail> void in_1(Head &h, Tail &...t) {
cin >> h;
in_1(t...);
}
template <typename Head> void print_1(Head &&h) { cout << h << '\n'; }
template <typename Head, typename... Tail> void print_1(Head &&h, Tail &&...t) {
cout << h << ' ';
print_1(t...);
}
//---------------------------------------------------------
const ll mod = 1000000007LL; // 10**9 + 7
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
friend ostream &operator<<(ostream &os, const mint &v) {
os << v.x;
return os;
}
};
//---------------------------------------------------------
struct mintcomb {
vector<mint> fact, ifact;
mintcomb(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) {
fact[i] = fact[i - 1] * i;
}
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) {
ifact[i - 1] = ifact[i] * i;
}
}
mint permutation(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[n - k];
}
mint combination(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
//---------------------------------------------------------
void solve() {
ll N;
in(N);
vll A(N);
vin(A);
multiset<ll> col;
for1(i, N) {
if (col.size() == 0 || A[i] <= *col.begin()) {
col.insert(A[i]);
continue;
}
auto it = col.upper_bound(A[i]);
it--;
col.erase(*it);
col.insert(A[i]);
}
print(col.size());
}
//---------------------------------------------------------
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(16);
cerr << fixed << setprecision(16);
solve();
}
| #define DEBUG 1
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using tll = tuple<ll, ll, ll>;
using vtll = vector<tll>;
using vvtll = vector<vtll>;
#define all(v) (v).begin(), (v).end()
#define for1(i, n) for (ll i = 0; i < (n); i++)
#define for2(i, m, n) for (ll i = (m); i < (n); i++)
#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))
#define rfor2(i, m, n) for (ll i = (m); i > (n); i--)
#define rfor3(i, m, n, d) for (ll i = (m); i > (n); i += (d))
#define PI 3.1415926535897932384626433832795028841971693993751L
#define INF 1111111111111111111LL
#define print(...) print_1(__VA_ARGS__)
#define in(...) in_1(__VA_ARGS__)
#if DEBUG
#define dump(...) dump_1(#__VA_ARGS__, __VA_ARGS__)
#define dumpa(...) dumpa_1(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#define dumpa(...)
#endif
template <typename Head> void dump_1(const char *str, Head &&h) {
cerr << str << ": " << h << '\n';
}
template <typename Head, typename... Tail>
void dump_1(const char *str, Head &&h, Tail &&...t) {
while (*str != ',') {
cerr << *str++;
}
cerr << ": " << h << ' ';
dump_1(str + 1, t...);
}
template <typename T>
void dumpa_1(const char *str, const T v[], const ll size) {
while (*str != ',') {
cerr << *str++;
}
cerr << ": ";
for1(i, size) {
if (i != 0) {
cerr << ' ';
}
cerr << v[i];
}
cerr << '\n';
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &v) {
os << v.first << ' ' << v.second;
return os;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &os, const tuple<T1, T2, T3> &v) {
os << get<0>(v) << ' ' << get<1>(v) << ' ' << get<2>(v);
return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &v) {
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ' ';
}
os << *it;
}
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &v) {
os << '{';
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) {
os << ", ";
}
os << it->first << ':' << it->second;
}
os << '}';
return os;
}
ll divup(ll nume, ll deno) {
assert(nume >= 0);
assert(deno > 0);
return (nume + deno - 1) / deno;
}
void Yes(void) { cout << "Yes\n"; }
void No(void) { cout << "No\n"; }
void YES(void) { cout << "YES\n"; }
void NO(void) { cout << "NO\n"; }
template <typename T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T> void vin(vector<T> &v) {
ll len = v.size();
for1(i, len) { cin >> v[i]; }
}
template <typename Head> void in_1(Head &h) { cin >> h; }
template <typename Head, typename... Tail> void in_1(Head &h, Tail &...t) {
cin >> h;
in_1(t...);
}
template <typename Head> void print_1(Head &&h) { cout << h << '\n'; }
template <typename Head, typename... Tail> void print_1(Head &&h, Tail &&...t) {
cout << h << ' ';
print_1(t...);
}
//---------------------------------------------------------
const ll mod = 1000000007LL; // 10**9 + 7
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
friend ostream &operator<<(ostream &os, const mint &v) {
os << v.x;
return os;
}
};
//---------------------------------------------------------
struct mintcomb {
vector<mint> fact, ifact;
mintcomb(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) {
fact[i] = fact[i - 1] * i;
}
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) {
ifact[i - 1] = ifact[i] * i;
}
}
mint permutation(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[n - k];
}
mint combination(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
//---------------------------------------------------------
void solve() {
ll N;
in(N);
vll A(N);
vin(A);
multiset<ll> col;
for1(i, N) {
if (col.size() == 0 || A[i] <= *col.begin()) {
col.insert(A[i]);
continue;
}
auto it = col.lower_bound(A[i]);
it--;
col.erase(it);
col.insert(A[i]);
}
print(col.size());
}
//---------------------------------------------------------
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(16);
cerr << fixed << setprecision(16);
solve();
}
| [
"call.function.change",
"call.arguments.change"
] | 781,296 | 781,295 | u426683236 | cpp |
p02973 | #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) \
REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
typedef pair<int, int> pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 2000020;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void yes(bool c) {
if (c)
print("Yes");
else
print("No");
};
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
void solve() {
int N;
cin >> N;
vector<int> A(N);
set<int> st;
int ans = 0;
REP(i, N) { cin >> A[i]; }
REP(i, N) {
auto itr = st.lower_bound(A[i]);
if (itr == st.begin()) {
ans++;
st.insert(A[i]);
} else {
itr--;
st.erase(itr);
st.insert(A[i]);
}
}
print(ans);
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
// int q; cin >> q;
// while (q--)
solve();
}
| #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) \
REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
typedef pair<int, int> pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 2000020;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void yes(bool c) {
if (c)
print("Yes");
else
print("No");
};
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
void solve() {
int N;
cin >> N;
vector<int> A(N);
multiset<int> st;
int ans = 0;
REP(i, N) { cin >> A[i]; }
REP(i, N) {
auto itr = st.lower_bound(A[i]);
if (itr == st.begin()) {
ans++;
st.insert(A[i]);
} else {
itr--;
st.erase(itr);
st.insert(A[i]);
}
}
print(ans);
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
// int q; cin >> q;
// while (q--)
solve();
}
| [
"variable_declaration.type.change"
] | 781,301 | 781,302 | u859396346 | cpp |
p02973 | // In The Name of Allah
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9 + 10;
int a[N], dp[N];
bool isVal(int x, int y) { return (y <= dp[x]); }
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[n - i];
for (int i = 0; i < n; i++)
a[i] = -a[i];
fill(dp, dp + N, -inf);
dp[0] = 0;
dp[1] = a[1];
for (int i = 2; i <= n; i++) {
int l = 0, r = n + 1;
while (r - l > 1) {
int mid = (l + r) / 2;
if (isVal(mid, a[i]))
l = mid;
else
r = mid;
}
dp[l + 1] = a[i];
}
int ans = 1;
for (int i = 1; i <= n; i++)
if (dp[i] != -inf)
ans = i;
cout << ans;
return 0;
}
| // In The Name of Allah
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9 + 10;
int a[N], dp[N];
bool isVal(int x, int y) { return (y <= dp[x]); }
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[n - i];
for (int i = 1; i <= n; i++)
a[i] = -a[i];
fill(dp, dp + N, -inf);
dp[0] = 0;
dp[1] = a[1];
for (int i = 2; i <= n; i++) {
int l = 0, r = n + 1;
while (r - l > 1) {
int mid = (l + r) / 2;
if (isVal(mid, a[i]))
l = mid;
else
r = mid;
}
dp[l + 1] = a[i];
}
int ans = 1;
for (int i = 1; i <= n; i++)
if (dp[i] != -inf)
ans = i;
cout << ans;
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 781,303 | 781,304 | u091252319 | cpp |
p02973 | // In The Name of Allah
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9 + 10;
int a[N], dp[N];
bool isVal(int x, int y) { return (y < dp[x]); }
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[n - i];
for (int i = 0; i < n; i++)
a[i] = -a[i];
fill(dp, dp + N, -inf);
dp[0] = 0;
dp[1] = a[1];
for (int i = 2; i <= n; i++) {
int l = 0, r = n + 1;
while (r - l > 1) {
int mid = (l + r) / 2;
if (isVal(mid, a[i]))
l = mid;
else
r = mid;
}
dp[l + 1] = a[i];
}
int ans = 1;
for (int i = 1; i <= n; i++)
if (dp[i] != -inf)
ans = i;
cout << ans;
return 0;
}
| // In The Name of Allah
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9 + 10;
int a[N], dp[N];
bool isVal(int x, int y) { return (y <= dp[x]); }
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[n - i];
for (int i = 1; i <= n; i++)
a[i] = -a[i];
fill(dp, dp + N, -inf);
dp[0] = 0;
dp[1] = a[1];
for (int i = 2; i <= n; i++) {
int l = 0, r = n + 1;
while (r - l > 1) {
int mid = (l + r) / 2;
if (isVal(mid, a[i]))
l = mid;
else
r = mid;
}
dp[l + 1] = a[i];
}
int ans = 1;
for (int i = 1; i <= n; i++)
if (dp[i] != -inf)
ans = i;
cout << ans;
return 0;
}
| [
"expression.operator.compare.change",
"function.return_value.change",
"expression.operation.binary.change",
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.loop.for.condition.change"
] | 781,305 | 781,304 | u091252319 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n;
cin >> n;
multiset<int> bst;
int a;
cin >> a;
bst.insert(a);
for (int i = 1; i < n; i++) {
cin >> a;
auto ptr = bst.lower_bound(a);
if (ptr == bst.begin()) {
bst.insert(a);
} else {
ptr--;
bst.erase(*ptr);
bst.insert(a);
}
}
cout << bst.size() << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n;
cin >> n;
multiset<int> bst;
int a;
cin >> a;
bst.insert(a);
for (int i = 1; i < n; i++) {
cin >> a;
auto ptr = bst.lower_bound(a);
if (ptr == bst.begin()) {
bst.insert(a);
} else {
ptr--;
bst.erase(ptr);
bst.insert(a);
}
}
cout << bst.size() << endl;
return 0;
}
| [
"call.arguments.change"
] | 781,306 | 781,307 | u388927326 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
vector<ll> a(n);
multiset<ll> st;
for (ll i = 0; i < n; i++)
cin >> a[i];
for (ll i = 0; i < n; i++) {
auto itr = st.lower_bound(a[i]);
if (st.begin() != itr) {
itr--;
st.erase(*itr);
st.insert(a[i]);
} else
st.insert(a[i]);
}
cout << st.size() << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
vector<ll> a(n);
multiset<ll> st;
for (ll i = 0; i < n; i++)
cin >> a[i];
for (ll i = 0; i < n; i++) {
auto itr = st.lower_bound(a[i]);
if (st.begin() != itr) {
itr--;
st.erase(itr);
st.insert(a[i]);
} else
st.insert(a[i]);
}
cout << st.size() << endl;
return 0;
} | [
"call.arguments.change"
] | 781,320 | 781,321 | u855186748 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
vector<ll> a(n);
multiset<ll> st;
for (ll i = 0; i < n; i++) {
cin >> a[i];
a[i] *= -1;
}
for (ll i = 0; i < n; i++) {
auto itr = st.upper_bound(a[i]);
if (st.end() != itr) {
st.erase(*itr);
st.insert(a[i]);
} else
st.insert(a[i]);
}
cout << st.size() << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
vector<ll> a(n);
multiset<ll> st;
for (ll i = 0; i < n; i++) {
cin >> a[i];
a[i] *= -1;
}
for (ll i = 0; i < n; i++) {
auto itr = st.upper_bound(a[i]);
if (st.end() != itr) {
st.erase(itr);
st.insert(a[i]);
} else
st.insert(a[i]);
}
cout << st.size() << endl;
return 0;
} | [
"call.arguments.change"
] | 781,322 | 781,323 | u855186748 | cpp |
p02973 | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define mind(a, b) (a > b ? b : a)
#define maxd(a, b) (a > b ? a : b)
#define absd(x) (x < 0 ? -(x) : x)
#define pow2(x) ((x) * (x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n - 1; i >= 0; --i)
#define repl(i, s, n) for (int i = s; i <= n; ++i)
#define replr(i, s, n) for (int i = n; i >= s; --i)
#define repf(i, s, n, j) for (int i = s; i <= n; i += j)
#define repe(e, obj) for (auto e : obj)
#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X, Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i, n, val) \
for (int i = 0; i < n; ++i) \
cout << val << " "; \
cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P>> pvqueue;
multiset<int> se;
int main() {
int n;
cin >> n;
rep(i, n) {
int a;
cin >> a;
auto it = se.lower_bound(-a + 1);
if (it != se.end()) {
se.erase(*it);
}
se.insert(-a);
}
cout << se.size() << endl;
return 0;
}
| #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define mind(a, b) (a > b ? b : a)
#define maxd(a, b) (a > b ? a : b)
#define absd(x) (x < 0 ? -(x) : x)
#define pow2(x) ((x) * (x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n - 1; i >= 0; --i)
#define repl(i, s, n) for (int i = s; i <= n; ++i)
#define replr(i, s, n) for (int i = n; i >= s; --i)
#define repf(i, s, n, j) for (int i = s; i <= n; i += j)
#define repe(e, obj) for (auto e : obj)
#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X, Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i, n, val) \
for (int i = 0; i < n; ++i) \
cout << val << " "; \
cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P>> pvqueue;
multiset<int> se;
int main() {
int n;
cin >> n;
rep(i, n) {
int a;
cin >> a;
auto it = se.lower_bound(-a + 1);
if (it != se.end()) {
se.erase(it);
}
se.insert(-a);
}
cout << se.size() << endl;
return 0;
}
| [
"call.arguments.change"
] | 781,324 | 781,325 | u226155577 | cpp |
p02973 | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define re register
#define ll long long
inline int gi() {
int f = 1, sum = 0;
char ch = getchar();
while (ch > '9' || ch < '0') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
sum = (sum << 3) + (sum << 1) + ch - '0';
ch = getchar();
}
return f * sum;
}
const int N = 500010;
int n, a[N], len, f[N], o[N];
int main() {
n = gi();
for (int i = 1; i <= n; i++)
a[i] = gi();
for (int i = n; i; i--) {
if (f[len] <= a[i])
f[++len] = a[i];
else {
int k = lower_bound(f + 1, f + len + 1, a[i]) - f;
f[k] = a[i];
}
}
printf("%d\n", len);
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define re register
#define ll long long
inline int gi() {
int f = 1, sum = 0;
char ch = getchar();
while (ch > '9' || ch < '0') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
sum = (sum << 3) + (sum << 1) + ch - '0';
ch = getchar();
}
return f * sum;
}
const int N = 500010;
int n, a[N], len, f[N], o[N];
int main() {
n = gi();
for (int i = 1; i <= n; i++)
a[i] = gi();
for (int i = n; i; i--) {
if (f[len] <= a[i])
f[++len] = a[i];
else {
int k = upper_bound(f + 1, f + len + 1, a[i]) - f;
f[k] = a[i];
}
}
printf("%d\n", len);
return 0;
}
| [
"identifier.change",
"call.function.change",
"expression.operation.binary.change"
] | 781,326 | 781,327 | u043445068 | cpp |
p02973 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
multiset<int, greater<int>> st;
int ans = 0;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
if (st.size() == 0) {
st.insert(a);
} else {
auto itr = st.upper_bound(a);
if (itr == st.end()) {
st.insert(a);
} else {
st.erase(*itr);
st.insert(a);
}
}
}
cout << st.size() << "\n";
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
multiset<int, greater<int>> st;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
if (st.size() == 0) {
st.insert(a);
} else {
auto itr = st.upper_bound(a);
if (itr == st.end()) {
st.insert(a);
} else {
st.erase(itr);
st.insert(a);
}
}
}
cout << st.size() << "\n";
return 0;
} | [
"variable_declaration.remove",
"call.arguments.change"
] | 781,328 | 781,329 | u334624175 | cpp |
p02973 | #include "bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int N, A[100000];
vector<int> dp;
int main() {
cin >> N;
for (int i = 0; i < N; i++)
cin >> A[i];
reverse(A, A + N);
dp.resize(N);
for (int i = 0; i < N; i++)
dp[i] = INT_MAX;
for (int i = 0; i < N; i++) {
*lower_bound(dp.begin(), dp.end(), A[i]) = A[i];
}
cout << lower_bound(dp.begin(), dp.end(), INT_MAX) - dp.begin() << endl;
}
| #include "bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int N, A[100000];
vector<int> dp;
int main() {
cin >> N;
for (int i = 0; i < N; i++)
cin >> A[i];
reverse(A, A + N);
dp.resize(N);
for (int i = 0; i < N; i++)
dp[i] = INT_MAX;
for (int i = 0; i < N; i++) {
*lower_bound(dp.begin(), dp.end(), A[i] + 1) = A[i];
}
cout << lower_bound(dp.begin(), dp.end(), INT_MAX) - dp.begin() << endl;
}
| [
"assignment.change"
] | 781,332 | 781,333 | u422592877 | cpp |
p02973 | #include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
int n;
int cnt = 0;
deque<int> q;
int main() {
cin >> n;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
auto it = lower_bound(q.begin(), q.end(), a);
if (it == q.begin()) {
q.push_front(a);
} else {
q[it - q.begin()] = a;
}
}
cout << q.size() << endl;
} | #include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
int n;
int cnt = 0;
deque<int> q;
int main() {
cin >> n;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
auto it = lower_bound(q.begin(), q.end(), a);
if (it == q.begin()) {
q.push_front(a);
} else {
q[it - q.begin() - 1] = a;
}
}
cout << q.size() << endl;
} | [
"assignment.change"
] | 781,338 | 781,339 | u585670083 | cpp |
p02973 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
const int MAX = 100001;
int main() {
int N;
int A[MAX];
deque<int> color;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
for (int i = 0; i < N; i++) {
int index = lower_bound(color.begin(), color.end(), A[i]) - color.begin();
if (index == 0) {
color.push_front(A[i]);
} else {
color[i - 1] = A[i];
}
}
cout << color.size() << endl;
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
const int MAX = 100001;
int main() {
int N;
int A[MAX];
deque<int> color;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
for (int i = 0; i < N; i++) {
int index = lower_bound(color.begin(), color.end(), A[i]) - color.begin();
if (index == 0) {
color.push_front(A[i]);
} else {
color[index - 1] = A[i];
}
}
cout << color.size() << endl;
return 0;
} | [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 781,340 | 781,341 | u105959367 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
#define N 100010
int a[N], dp[N];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
dp[1] = a[1];
int len = 1;
for (int i = 2; i <= n; i++) {
if (dp[len] >= a[i])
dp[++len] = a[i];
else {
int p, l = 1, r = len;
while (l < r) {
int m = l + r >> 1;
if (a[m] >= a[i])
l = m + 1;
else
r = m;
}
dp[l] = a[i];
}
}
cout << len << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define N 100010
int a[N], dp[N];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
dp[1] = a[1];
int len = 1;
for (int i = 2; i <= n; i++) {
if (dp[len] >= a[i])
dp[++len] = a[i];
else {
int p, l = 1, r = len;
while (l < r) {
int m = l + r >> 1;
if (dp[m] >= a[i])
l = m + 1;
else
r = m;
}
dp[l] = a[i];
}
}
cout << len << endl;
return 0;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 781,342 | 781,343 | u820628270 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int a[maxn];
int dp[maxn];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n / 2; i++)
swap(a[i], a[n - i + 1]);
dp[1] = a[1];
int k = 1;
for (int i = 2; i <= n; i++) {
if (a[i] + 1 > dp[k])
dp[++k] = a[i];
else {
dp[upper_bound(dp + 1, dp + 1 + k, a[i] + 1) - dp] = a[i];
}
}
cout << k << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int a[maxn];
int dp[maxn];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n / 2; i++)
swap(a[i], a[n - i + 1]);
dp[1] = a[1];
int k = 1;
for (int i = 2; i <= n; i++) {
if (a[i] + 1 > dp[k])
dp[++k] = a[i];
else {
dp[upper_bound(dp + 1, dp + 1 + k, a[i]) - dp] = a[i];
}
}
cout << k << endl;
return 0;
}
| [
"expression.operation.binary.remove"
] | 781,346 | 781,347 | u914135866 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int a[maxn];
int dp[maxn];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n / 2; i++)
swap(a[i], a[n - i + 1]);
dp[1] = a[1];
int k = 1;
for (int i = 2; i <= n; i++) {
if (a[i] + 1 > dp[k])
dp[++k] = a[i];
else {
dp[upper_bound(dp + 1, dp + 1 + k, a[i] + 1) - dp] = a[i];
}
}
cout << k << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int a[maxn];
int dp[maxn];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n / 2; i++)
swap(a[i], a[n - i + 1]);
dp[1] = a[1];
int k = 1;
for (int i = 2; i <= n; i++) {
if (a[i] + 1 > dp[k])
dp[++k] = a[i];
else {
dp[lower_bound(dp + 1, dp + 1 + k, a[i] + 1) - dp] = a[i];
}
}
cout << k << endl;
return 0;
}
| [
"assignment.variable.change",
"identifier.change",
"call.function.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 781,346 | 781,348 | u914135866 | cpp |
p02973 | #include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
int main() {
int N;
cin >> N;
vector<int> A(N);
rep(i, N) cin >> A[i];
multiset<int> mst;
mst.insert(A[0]);
for (int i = 1; i < N; i++) {
if (A[i] > *(mst.begin())) {
auto it = mst.lower_bound(A[i]);
it--;
mst.erase(*it);
}
mst.insert(A[i]);
}
cout << mst.size() << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
int main() {
int N;
cin >> N;
vector<int> A(N);
rep(i, N) cin >> A[i];
multiset<int> mst;
mst.insert(A[0]);
for (int i = 1; i < N; i++) {
if (A[i] > *(mst.begin())) {
auto it = mst.lower_bound(A[i]);
it--;
mst.erase(it);
}
mst.insert(A[i]);
}
cout << mst.size() << endl;
return 0;
} | [
"import.add",
"call.arguments.change"
] | 781,353 | 781,354 | u608258653 | cpp |
p02973 | #include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
using namespace std;
using ll = long long;
constexpr int mo = 1e9 + 7;
constexpr int mod = mo;
constexpr ll inf = 1ll << 62;
int main() {
int n;
cin >> n;
multiset<int> s;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
auto it = s.lower_bound(a);
if (s.begin() == it) {
s.insert(a);
} else {
it--;
s.erase(*it);
s.insert(a);
}
}
cout << s.size() << endl;
return 0;
}
| #include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
using namespace std;
using ll = long long;
constexpr int mo = 1e9 + 7;
constexpr int mod = mo;
constexpr ll inf = 1ll << 62;
int main() {
int n;
cin >> n;
multiset<int> s;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
auto it = s.lower_bound(a);
if (s.begin() == it) {
s.insert(a);
} else {
it--;
s.erase(it);
s.insert(a);
}
}
cout << s.size() << endl;
return 0;
}
| [
"call.arguments.change"
] | 781,360 | 781,361 | u699193595 | cpp |
p02973 | #include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
using namespace std;
using ll = long long;
constexpr int mo = 1e9 + 7;
constexpr int mod = mo;
constexpr ll inf = 1ll << 62;
int main() {
int n;
cin >> n;
set<int> s;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
auto it = s.lower_bound(a);
if (s.begin() == it) {
s.insert(a);
} else {
it--;
s.erase(*it);
s.insert(a);
}
}
cout << s.size() << endl;
return 0;
}
| #include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
using namespace std;
using ll = long long;
constexpr int mo = 1e9 + 7;
constexpr int mod = mo;
constexpr ll inf = 1ll << 62;
int main() {
int n;
cin >> n;
multiset<int> s;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
auto it = s.lower_bound(a);
if (s.begin() == it) {
s.insert(a);
} else {
it--;
s.erase(it);
s.insert(a);
}
}
cout << s.size() << endl;
return 0;
}
| [
"variable_declaration.type.change",
"call.arguments.change"
] | 781,362 | 781,361 | u699193595 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
int n, a[100005];
int val[100005];
int main() {
scanf("%d", &n);
rep(i, n) scanf("%d", &a[i]);
val[0] = -1;
for (int i = 1; i < 100005; i++)
val[i] = INF + 4;
for (int i = n - 1; i >= 0; i--) {
int b = upper_bound(val, val + 100005, a[i]) - val;
val[b] = a[i];
}
for (int i = 100001; i >= 0; i--) {
if (val[i] != INF) {
cout << i << endl;
return 0;
}
}
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
int n, a[100005];
int val[100005];
int main() {
scanf("%d", &n);
rep(i, n) scanf("%d", &a[i]);
val[0] = -1;
for (int i = 1; i < 100005; i++)
val[i] = INF + 4;
for (int i = n - 1; i >= 0; i--) {
int b = upper_bound(val, val + 100005, a[i]) - val;
val[b] = a[i];
}
for (int i = 100001; i >= 0; i--) {
if (val[i] != INF + 4) {
cout << i << endl;
return 0;
}
}
}
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 781,363 | 781,364 | u316170293 | cpp |
p02973 | #include <bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll, ll>>
#define pii pair<int, int>
#define REP(i, a) for (int(i) = 0; (i) < (a); (i)++)
#define RREP(i, a) for (int(i) = a - 1; (i) >= (0); (i)--)
#define REP2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define MOD 1000000007
#define INF 0x7FFFFFFF
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x, 0, sizeof(x))
typedef long long ll;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
vll A(N);
REP(i, N) cin >> A[i];
reverse(ALL(A));
vll dp(N, INF);
REP(i, N) * lower_bound(ALL(dp), A[i]) = A[i];
cout << lower_bound(ALL(dp), INF) - dp.begin() << "\n";
return 0;
}
| #include <bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll, ll>>
#define pii pair<int, int>
#define REP(i, a) for (int(i) = 0; (i) < (a); (i)++)
#define RREP(i, a) for (int(i) = a - 1; (i) >= (0); (i)--)
#define REP2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define MOD 1000000007
#define INF 0x7FFFFFFF
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x, 0, sizeof(x))
typedef long long ll;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
vll A(N);
REP(i, N) { cin >> A[i]; }
reverse(ALL(A));
vll dp(N, INF);
REP(i, N) { *upper_bound(ALL(dp), A[i]) = A[i]; }
cout << lower_bound(ALL(dp), INF) - dp.begin() << "\n";
return 0;
} | [
"assignment.variable.change",
"identifier.change",
"call.function.change",
"expression.operation.binary.change"
] | 781,369 | 781,370 | u026483463 | cpp |
p02973 | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
vector<ll> A(N);
Rep(i, N) { cin >> A[i]; }
multiset<ll> color;
Rep(i, N) {
auto itr = color.upper_bound(-A[i]);
if (itr != color.end()) {
color.erase(*itr);
}
color.insert(-A[i]);
// for (auto itr = color.begin(); itr != color.end(); itr++) {
// cout << -*itr << " ";
// }
// cout << "\n";
}
// for (auto itr = color.begin(); itr != color.end(); itr++) {
// cout << -*itr << " ";
// }
// cout << "\n";
cout << color.size() << "\n";
} | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
vector<ll> A(N);
Rep(i, N) { cin >> A[i]; }
multiset<ll> color;
ll num = 0;
Rep(i, N) {
auto itr = color.upper_bound(-A[i]);
if (itr != color.end()) {
color.erase(itr);
}
color.insert(-A[i]);
}
cout << color.size() << "\n";
}
| [
"variable_declaration.add",
"call.arguments.change"
] | 781,388 | 781,389 | u017271745 | cpp |
p02973 | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
vector<ll> A(N);
Rep(i, N) { cin >> A[i]; }
multiset<ll> color;
Rep(i, N) {
auto itr = color.upper_bound(-A[i]);
if (itr != color.end()) {
color.erase(*itr);
}
color.insert(-A[i]);
// for (auto itr = color.begin(); itr != color.end(); itr++) {
// cout << -*itr << " ";
// }
// cout << "\n";
}
// for (auto itr = color.begin(); itr != color.end(); itr++) {
// cout << -*itr << " ";
// }
// cout << "\n";
cout << color.size() << "\n";
} | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
vector<ll> A(N);
Rep(i, N) { cin >> A[i]; }
multiset<ll> color;
Rep(i, N) {
auto itr = color.upper_bound(-A[i]);
// cout << *itr << "\n";
if (itr != color.end()) {
color.erase(itr);
}
// color.erase(*itr);
color.insert(-A[i]);
// for (auto itr = color.begin(); itr != color.end(); itr++) {
// cout << -*itr << " ";
// }
// cout << "\n";
}
// for (auto itr = color.begin(); itr != color.end(); itr++) {
// cout << -*itr << " ";
// }
// cout << "\n";
cout << color.size() << "\n";
}
| [
"call.arguments.change"
] | 781,388 | 781,390 | u017271745 | cpp |
p02973 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
deque<int> col;
col.push_front(a[0]);
int left, right, mid;
for (int i = 1; i < n; i++) {
if (a[i] <= col[0])
col.push_front(a[i]);
else {
left = 0;
right = col.size() - 1;
while (right - left > 1) {
mid = left + (right - left) / 2;
if (a[i] > col[mid])
left = mid;
else
right = mid;
}
col[left] = a[i];
}
}
cout << col.size() << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
deque<int> col;
col.push_front(a[0]);
int left, right, mid;
for (int i = 1; i < n; i++) {
if (a[i] <= col[0])
col.push_front(a[i]);
else {
left = -1;
right = col.size();
while (right - left > 1) {
mid = left + (right - left) / 2;
if (a[i] > col[mid])
left = mid;
else
right = mid;
}
col[left] = a[i];
}
}
cout << col.size() << endl;
return 0;
} | [
"literal.number.change",
"assignment.value.change",
"expression.operation.binary.remove"
] | 781,391 | 781,392 | u115306811 | cpp |
p02973 | #include <algorithm>
#include <deque>
#include <iostream>
using namespace std;
int main() {
long N;
cin >> N;
deque<long> LDS;
for (size_t n = 0; n < N; ++n) {
long A;
cin >> A;
auto it = lower_bound(LDS.begin(), LDS.end(), A);
if (it == LDS.begin())
LDS.push_front(A);
else
*it = A;
}
cout << LDS.size() << endl;
return 0;
}
| #include <algorithm>
#include <deque>
#include <iostream>
using namespace std;
int main() {
long N;
cin >> N;
deque<long> LDS;
for (size_t n = 0; n < N; ++n) {
long A;
cin >> A;
auto it = lower_bound(LDS.begin(), LDS.end(), A);
if (it == LDS.begin())
LDS.push_front(A);
else
*(--it) = A;
}
cout << LDS.size() << endl;
return 0;
}
| [] | 781,393 | 781,394 | u762603420 | cpp |
p02973 | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
int N, res = 1;
cin >> N;
vector<int> A, B(N + 1, INF);
for (int i = 0; i < N; i++) {
int a;
cin >> a;
A.push_back(-a);
}
for (int i = 0; i < N; i++) {
*lower_bound(B.begin(), B.end(), A[i]) = A[i];
}
cout << (lower_bound(B.begin(), B.end(), INF) - B.begin()) << endl;
} | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
int N, res = 1;
cin >> N;
vector<int> A, B(N + 1, INF);
for (int i = 0; i < N; i++) {
int a;
cin >> a;
A.push_back(-a);
}
for (int i = 0; i < N; i++) {
*lower_bound(B.begin(), B.end(), A[i] + 1) = A[i];
}
cout << (lower_bound(B.begin(), B.end(), INF) - B.begin()) << endl;
} | [
"assignment.change"
] | 781,395 | 781,396 | u723550619 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0);
#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;
int main(void) {
IOS int n;
cin >> n;
vector<int> v;
int a;
cin >> a;
v.emplace_back(a);
REP(i, n - 1) {
int x;
cin >> x;
if (v.back() >= x) {
v.emplace_back(x);
} else {
auto it = lower_bound(ALL(v), x, greater<int>());
*it = x;
}
}
cout << v.size() << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0);
#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;
int main(void) {
IOS int n;
cin >> n;
vector<int> v;
int a;
cin >> a;
v.emplace_back(a);
REP(i, n - 1) {
int x;
cin >> x;
if (v.back() >= x) {
v.emplace_back(x);
} else {
auto it = upper_bound(ALL(v), x, greater<int>());
*it = x;
}
}
cout << v.size() << endl;
return 0;
} | [
"identifier.change",
"call.function.change"
] | 781,397 | 781,398 | u330661451 | cpp |
p02973 | #include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int main() {
int n;
cin >> n;
vector<LL> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
reverse(a.begin(), a.end());
vector<LL> dp(n, 1e9);
dp[0] = a[0];
LL length = 1;
for (int i = 1; i < n; i++) {
if (dp[length - 1] <= a[i])
dp[length++] = a[i];
else
*lower_bound(dp.begin(), dp.begin() + length, a[i]) = a[i];
}
cout << length << endl;
} | #include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int main() {
int n;
cin >> n;
vector<LL> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
reverse(a.begin(), a.end());
vector<LL> dp(n, 1e9);
dp[0] = a[0];
LL length = 1;
for (int i = 1; i < n; i++) {
if (dp[length - 1] <= a[i])
dp[length++] = a[i];
else
*upper_bound(dp.begin(), dp.begin() + length, a[i]) = a[i];
}
cout << length << endl;
} | [
"assignment.variable.change",
"identifier.change",
"call.function.change"
] | 781,399 | 781,400 | u392423112 | cpp |
p02973 | // ~/Remember,remember the 6th of March
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
using namespace std;
int main() {
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
arr[i] *= -1;
}
vector<int> lcs;
for (int i = 0; i < n; i++) {
int ind = upper_bound(lcs.begin(), lcs.end(), arr[i]) - lcs.begin();
if (ind == lcs.size())
lcs.push_back(arr[i]);
else
lcs[ind] = arr[arr[i]];
}
cout << lcs.size() << endl;
return 0;
}
| // ~/Remember,remember the 6th of March
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
using namespace std;
int main() {
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
arr[i] *= -1;
}
vector<int> lcs;
for (int i = 0; i < n; i++) {
int ind = upper_bound(lcs.begin(), lcs.end(), arr[i]) - lcs.begin();
if (ind == lcs.size())
lcs.push_back(arr[i]);
else
lcs[ind] = arr[i];
}
cout << lcs.size() << endl;
return 0;
} | [] | 781,403 | 781,404 | u692176965 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0, i##_max = (N); i < i##_max; ++i)
#define repp(i, l, r) for (int i = (l), i##_max = (r); i < i##_max; ++i)
#define per(i, N) for (int i = (N)-1; i >= 0; --i)
#define perr(i, l, r) for (int i = r - 1, i##_min(l); i >= i##_min; --i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP \
cin.tie(0); \
ios::sync_with_stdio(false);
#define MAX_I INT_MAX // 1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX // 1e9
#define MAX_LL LLONG_MAX // 1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX // 1e19
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<char, char> PCC;
typedef pair<ll, ll> PLL;
typedef pair<char, int> PCI;
typedef pair<int, char> PIC;
typedef pair<ll, int> PLI;
typedef pair<int, ll> PIL;
typedef pair<ll, char> PLC;
typedef pair<char, ll> PCL;
inline void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
inline void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
inline void Yay(bool b) { cout << (b ? "Yay!" : ":(") << endl; }
int main(void) {
SPEEDUP
cout << setprecision(15);
int N;
cin >> N;
vector<int> v(N);
rep(i, N) cin >> v[i];
vector<int> w(N, MAX_I);
rep(i, N) { *upper_bound(all(w), -v[i]) = -v[i]; }
cout << upper_bound(all(w), MAX_I) - w.begin() << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0, i##_max = (N); i < i##_max; ++i)
#define repp(i, l, r) for (int i = (l), i##_max = (r); i < i##_max; ++i)
#define per(i, N) for (int i = (N)-1; i >= 0; --i)
#define perr(i, l, r) for (int i = r - 1, i##_min(l); i >= i##_min; --i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP \
cin.tie(0); \
ios::sync_with_stdio(false);
#define MAX_I INT_MAX // 1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX // 1e9
#define MAX_LL LLONG_MAX // 1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX // 1e19
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<char, char> PCC;
typedef pair<ll, ll> PLL;
typedef pair<char, int> PCI;
typedef pair<int, char> PIC;
typedef pair<ll, int> PLI;
typedef pair<int, ll> PIL;
typedef pair<ll, char> PLC;
typedef pair<char, ll> PCL;
inline void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
inline void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
inline void Yay(bool b) { cout << (b ? "Yay!" : ":(") << endl; }
int main(void) {
SPEEDUP
cout << setprecision(15);
int N;
cin >> N;
vector<int> v(N);
rep(i, N) cin >> v[i];
vector<int> w(N, MAX_I);
rep(i, N) { *upper_bound(all(w), -v[i]) = -v[i]; }
cout << lower_bound(all(w), MAX_I) - w.begin() << endl;
return 0;
}
| [
"identifier.change",
"call.function.change",
"io.output.change"
] | 781,407 | 781,408 | u069450081 | cpp |
p02973 | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main() {
int N;
cin >> N;
vector<int> a(N);
rep(i, N) cin >> a[i];
vector<vector<int>> colors;
colors.push_back(vector<int>(1, a[0]));
for (int i = 1; i < N; i++) {
// cout << "a[" << i << "] " << a[i] << ' ';
if (a[i] <=
colors[colors.size() - 1][colors[colors.size() - 1].size() - 1]) {
colors.push_back(vector<int>(1, a[i]));
// cout << "i: " << i << endl;
} else {
// cout << " i: " << i << ' ';
int left = -1;
int right = colors.size();
int mid;
while (left + 1 < right) {
mid = (left + right) / 2;
if (a[i] < colors[mid][colors[mid].size() - 1]) {
left = mid;
} else {
right = mid;
}
}
// cout << "mid " << right << endl;
colors[right].push_back(a[i]);
}
}
// rep(i, colors.size()) {
// rep(j, colors[i].size()) {
// cout << colors[i][j] << ' ';
// }
// cout << endl;
// }
cout << colors.size() << endl;
return 0;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main() {
int N;
cin >> N;
vector<int> a(N);
rep(i, N) cin >> a[i];
vector<vector<int>> colors;
colors.push_back(vector<int>(1, a[0]));
for (int i = 1; i < N; i++) {
// cout << "a[" << i << "] " << a[i] << ' ';
if (a[i] <=
colors[colors.size() - 1][colors[colors.size() - 1].size() - 1]) {
colors.push_back(vector<int>(1, a[i]));
// cout << "i: " << i << endl;
} else {
// cout << " i: " << i << ' ';
int left = -1;
int right = colors.size();
int mid;
while (left + 1 < right) {
mid = (left + right) / 2;
if (a[i] <= colors[mid][colors[mid].size() - 1]) {
left = mid;
} else {
right = mid;
}
}
// cout << "mid " << right << endl;
colors[right].push_back(a[i]);
}
}
cout << colors.size() << endl;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 781,412 | 781,413 | u017293723 | cpp |
p02973 | #include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (a); i <= (b); i++)
#define END(x) \
do { \
cout << (x) << endl; \
exit(0); \
} while (0)
#define debug(x) \
do { \
cerr << #x << ": " << x << "\n"; \
} while (0)
#define debugv(x) \
do { \
cerr << #x << ": "; \
for (auto &e : (x)) \
cerr << e << " "; \
cerr << "\n"; \
} while (0)
#define exp2(x) (1LL << (x))
#define cond(a, b, c) ((a) ? (b) : (c))
using ll = long long;
using namespace std;
int A[100 * 1000 + 100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
rep(i, 1, N) cin >> A[i];
set<int> s;
s.insert(A[1]);
int ans = 1;
rep(i, 2, N) {
auto itlow = s.lower_bound(A[i] - 1);
while ((itlow == s.end() or *itlow >= A[i]) and itlow != s.begin())
itlow--;
if (*itlow < A[i]) {
s.erase(itlow);
} else {
ans++;
}
s.insert(A[i]);
}
END(ans);
}
| #include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (a); i <= (b); i++)
#define END(x) \
do { \
cout << (x) << endl; \
exit(0); \
} while (0)
#define debug(x) \
do { \
cerr << #x << ": " << x << "\n"; \
} while (0)
#define debugv(x) \
do { \
cerr << #x << ": "; \
for (auto &e : (x)) \
cerr << e << " "; \
cerr << "\n"; \
} while (0)
#define exp2(x) (1LL << (x))
#define cond(a, b, c) ((a) ? (b) : (c))
using ll = long long;
using namespace std;
int A[100 * 1000 + 100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
rep(i, 1, N) cin >> A[i];
multiset<int> s;
s.insert(A[1]);
int ans = 1;
rep(i, 2, N) {
auto itlow = s.lower_bound(A[i]);
while ((itlow == s.end() or *itlow >= A[i]) and itlow != s.begin())
itlow--;
if (*itlow < A[i]) {
s.erase(itlow);
} else {
ans++;
}
s.insert(A[i]);
}
END(ans);
}
| [
"variable_declaration.type.change",
"expression.operation.binary.remove"
] | 781,416 | 781,417 | u993688697 | cpp |
p02973 | #include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (a); i <= (b); i++)
#define END(x) \
do { \
cout << (x) << endl; \
exit(0); \
} while (0)
#define debug(x) \
do { \
cerr << #x << ": " << x << "\n"; \
} while (0)
#define debugv(x) \
do { \
cerr << #x << ": "; \
for (auto &e : (x)) \
cerr << e << " "; \
cerr << "\n"; \
} while (0)
#define exp2(x) (1LL << (x))
#define cond(a, b, c) ((a) ? (b) : (c))
using ll = long long;
using namespace std;
int A[100 * 1000 + 100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
rep(i, 1, N) cin >> A[i];
set<int> s;
s.insert(A[1]);
int ans = 1;
rep(i, 2, N) {
auto itlow = s.lower_bound(A[i]);
while ((itlow == s.end() or *itlow >= A[i]) and itlow != s.begin())
itlow--;
if (*itlow < A[i]) {
s.erase(itlow);
} else {
ans++;
}
s.insert(A[i]);
}
END(ans);
}
| #include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (a); i <= (b); i++)
#define END(x) \
do { \
cout << (x) << endl; \
exit(0); \
} while (0)
#define debug(x) \
do { \
cerr << #x << ": " << x << "\n"; \
} while (0)
#define debugv(x) \
do { \
cerr << #x << ": "; \
for (auto &e : (x)) \
cerr << e << " "; \
cerr << "\n"; \
} while (0)
#define exp2(x) (1LL << (x))
#define cond(a, b, c) ((a) ? (b) : (c))
using ll = long long;
using namespace std;
int A[100 * 1000 + 100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
rep(i, 1, N) cin >> A[i];
multiset<int> s;
s.insert(A[1]);
int ans = 1;
rep(i, 2, N) {
auto itlow = s.lower_bound(A[i]);
while ((itlow == s.end() or *itlow >= A[i]) and itlow != s.begin())
itlow--;
if (*itlow < A[i]) {
s.erase(itlow);
} else {
ans++;
}
s.insert(A[i]);
}
END(ans);
}
| [
"variable_declaration.type.change"
] | 781,418 | 781,417 | u993688697 | cpp |
p02973 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
#define ITR(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
constexpr ll mod = 1000000007;
ll mpow(ll x,
ll n) { // x^n(mod) ←普通にpow(x,n)では溢れてしまうため,随時mod計算
// 2分累乗法だから早い
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % mod;
x = x * x % mod;
n = n >> 1;
}
return ans;
}
ll inv_mod(ll a) { return mpow(a, mod - 2); }
bool square(ll a) {
ll n = (ll)sqrt(a);
return a == n * n;
}
int digitsum(ll N, int a) {
if (N == 0)
return 0;
int ret = 0;
ret += digitsum(N / a, a) + N % a;
return ret;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }; // xとyの最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } // xとyの最小公倍数
void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; }
vector<ll> splitint(string n, int a) {
int Len = n.length();
if (a < 0 || Len < a)
return {-1, -1};
string left, right;
if (a != 0)
left = n.substr(0, a);
if (a != Len)
right = n.substr(a);
return {stoll(left), stoll(right)};
}
class mint {
private:
ll _num, _mod;
mint set(ll num) {
_num = num;
if (_num >= 0)
_num %= _mod;
else
_num += (1 - (_num + 1) / _mod) * _mod;
return *this;
}
ll imod(ll n) { return mpow(n, _mod - 2); }
public:
mint() {
_num = 0;
_mod = mod;
}
mint(ll num) {
_mod = mod;
_num = num % mod;
}
mint(ll num, ll M) {
_mod = M;
set(num);
}
mint(const mint &cp) {
_num = cp._num;
_mod = cp._mod;
}
mint operator=(ll x) { return mint(x % _mod, _mod); }
mint operator+(ll x) { return mint(_num + (x % _mod), _mod); }
mint operator-(ll x) { return mint(_num - (x % _mod), _mod); }
mint operator*(ll x) { return mint(_num * (x % _mod), _mod); }
mint operator/(ll x) { return mint(_num * imod(x), _mod); }
mint operator+=(ll x) { return set(_num + (x % _mod)); }
mint operator-=(ll x) { return set(_num - (x % _mod)); }
mint operator*=(ll x) { return set(_num * (x % _mod)); }
mint operator/=(ll x) { return set(_num * imod(x)); }
mint operator+(mint x) { return mint(_num + x._num, _mod); }
mint operator-(mint x) { return mint(_num - x._num, _mod); }
mint operator*(mint x) { return mint(_num * x._num, _mod); }
mint operator/(mint x) { return mint(_num * imod(x._num), _mod); }
mint operator+=(mint x) { return set(_num + x._num); }
mint operator-=(mint x) { return set(_num - x._num); }
mint operator*=(mint x) { return set(_num * x._num); }
mint operator/=(mint x) { return set(_num * imod(x._num)); }
friend mint operator+(ll x, mint m) {
return mint(m._num + (x % m._mod), m._mod);
}
friend mint operator-(ll x, mint m) {
return mint(m._num - (x % m._mod), m._mod);
}
friend mint operator*(ll x, mint m) {
return mint(m._num * (x % m._mod), m._mod);
}
friend mint operator/(ll x, mint m) {
return mint(m.imod(m._num) * x, m._mod);
}
explicit operator ll() { return _num; }
explicit operator int() { return _num; }
friend ostream &operator<<(ostream &os, const mint &x) {
os << x._num;
return os;
}
friend istream &operator>>(istream &is, mint &x) {
ll val;
is >> val;
x.set(val);
return is;
}
};
class MAT {
private:
int row, col;
vector<vector<double>> _A;
MAT set(vector<vector<double>> A) {
_A = A;
return *this;
}
public:
MAT() {}
MAT(int n, int m) {
if (n < 1 || m < 0) {
cout << "err Matrix::Matrix" << endl;
exit(1);
}
row = n;
col = m ? m : n; // m=0のとき単位行列を作る
REP(i, row) {
vector<double> a(col);
_A.push_back(a);
REP(j, col) _A[i][j] = 0;
}
// 値の初期化
if (m == 0)
REP(i, n) _A[i][i] = 1.0;
}
MAT(const MAT &cp) {
_A = cp._A;
row = cp.row;
col = cp.col;
}
double *operator[](int i) { return _A[i].data(); }
MAT operator=(vector<vector<double>> x) { return set(x); }
MAT operator+(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator+" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j];
return r;
}
MAT operator-(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator-" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j];
return r;
}
MAT operator*(MAT x) {
if (col != x.row) {
cout << "err Matrix::operator*" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, x.col);
REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j];
return r;
}
MAT operator/(double a) {
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a;
return r;
}
MAT operator^(ll n) {
if (row != col) {
cout << "err Matrix::operator^" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, 0), A = *this;
while (n) {
if (n & 1)
r *= A;
A *= A;
n >>= 1;
}
return r;
}
MAT operator+=(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator+=" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j];
return set(r._A);
}
MAT operator-=(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator-=" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j];
return set(r._A);
}
MAT operator*=(MAT x) {
if (col != x.row) {
cout << "err Matrix::operator*" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, x.col);
REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j];
return set(r._A);
}
MAT operator/=(double a) {
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a;
return r;
}
friend MAT operator*(double n, MAT x) {
MAT r(x.row, x.col);
REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j];
return r;
}
friend MAT operator*(MAT x, double n) {
MAT r(x.row, x.col);
REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j];
return r;
}
explicit operator vector<vector<double>>() { return _A; }
friend ostream &operator<<(ostream &os, const MAT &x) {
REP(i, x.row) REP(j, x.col) os << x._A[i][j] << " \n"[j == x.col - 1];
return os;
}
int size_row() { return row; }
int size_col() { return col; }
MAT transpose() {
MAT r(col, row);
REP(i, col) REP(j, row) r[i][j] = _A[j][i];
return r;
}
};
class UnionFind { // UnionFind木
private:
vector<int> Parent;
public:
UnionFind(int N) {
Parent.resize(N);
REP(i, N) Parent[i] = -1;
}
int root(int A) {
if (Parent[A] < 0)
return A;
else
return Parent[A] = root(Parent[A]);
}
int size(int A) { return -Parent[root(A)]; }
bool connect(int A, int B) {
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
class Factorial { //階乗とその逆元を求めて計算に利用するクラス
private:
vector<ll> fac;
vector<ll> ifac;
public:
Factorial(ll N) {
fac.push_back(1);
REP(i, N) fac.push_back(fac[i] * (i + 1) % mod);
ifac.resize(N + 1);
ifac[N] = inv_mod(fac[N]);
REP(i, N) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
}
ll fact(ll a) { return fac[a]; }
ll ifact(ll a) { return ifac[a]; }
ll cmb(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0 || b < 0)
return 0;
ll tmp = ifact(a - b) * ifact(b) % mod;
return tmp * fac[a] % mod;
}
ll per(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0 || b < 0)
return 0;
return fac[a] * ifac[a - b] % mod;
}
};
class SOSU {
private:
vector<ll> Prime_Number;
public:
SOSU(int N) {
set<ll> arr;
REP(i, N - 1) arr.insert(i + 2);
while (int n = *arr.begin()) {
if (n > sqrt(N))
break;
Prime_Number.push_back(n);
rep(i, 1, N / n + 1) arr.erase(n * i);
}
ITR(itr, arr) Prime_Number.push_back(*itr);
}
ll operator[](int i) { return Prime_Number[i]; }
int count() { return Prime_Number.size(); }
bool isPrime(int q) { return binary_search(All(Prime_Number), q); }
};
struct Solutions {
ll napsack(int kinds, int MAX_W, const vl weight, const vl cost) {
vector<vector<ll>> dp(kinds + 1, vector<ll>(MAX_W + 1, 0));
REP(i, kinds) REP(j, MAX_W + 1) {
if (j < weight[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + cost[i]);
}
return dp[kinds][MAX_W];
}
ll unlimited_napsack(int kinds, int MAX_W, const vl weight, const vl cost) {
vector<vector<ll>> dp(kinds + 1, vector<ll>(MAX_W + 1, 0));
REP(i, kinds) REP(j, MAX_W + 1) {
if (j < weight[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - weight[i]] + cost[i]);
}
return dp[kinds][MAX_W];
}
ll Partition_Func(int n, int k) {
vector<vector<ll>> dp(k + 1, vector<ll>(n + 1, 0));
dp[0][0] = 1;
rep(i, 1, k + 1) REP(j, n + 1) {
if (j - i >= 0)
dp[i][j] = (dp[i][j - i] + dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
return dp[k][n];
}
int LCS(string s, string t) {
int n = s.length(), m = s.length();
vector<vector<int>> dp(n + 1, vector<int>(m + 1));
REP(i, n) REP(j, m) {
if (s[i] == t[j])
dp[i + 1][j + 1] = dp[i][j] + 1;
else
dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
}
return dp[n][m];
}
int LIS(const vector<ll> a) {
int n = a.size();
ll INF = 1 << 28;
vector<ll> dp(n + 1, INF);
REP(i, n) * lower_bound(All(dp), a[i]) = a[i];
int k = lower_bound(All(dp), INF) - dp.begin();
return k;
}
};
struct edge {
int from;
int to;
ll cost;
void push(int a, int b, int c) {
from = a;
to = b;
cost = c;
}
bool operator<(const edge &y) const {
if (cost != y.cost)
return cost < y.cost;
else if (to != y.to)
return to < y.to;
else
return from < y.from;
}
bool operator>(const edge &y) const {
if (cost != y.cost)
return cost > y.cost;
else if (to != y.to)
return to > y.to;
else
return from > y.from;
}
bool operator==(const edge &y) const { return *this == y; }
};
class lca {
public:
const int n = 0;
const int log2_n = 0;
std::vector<std::vector<int>> parent;
std::vector<int> depth;
lca() {}
lca(const Graph &g, int root)
: n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)),
depth(n) {
dfs(g, root, -1, 0);
for (int k = 0; k + 1 < log2_n; k++) {
for (int v = 0; v < (int)g.size(); v++) {
if (parent[k][v] < 0)
parent[k + 1][v] = -1;
else
parent[k + 1][v] = parent[k][parent[k][v]];
}
}
}
void dfs(const Graph &g, int v, int p, int d) {
parent[0][v] = p;
depth[v] = d;
REP(j, g[v].size()) {
if (g[v][j] != p)
dfs(g, g[v][j], v, d + 1);
}
}
int get(int u, int v) {
if (depth[u] > depth[v])
std::swap(u, v);
for (int k = 0; k < log2_n; k++) {
if ((depth[v] - depth[u]) >> k & 1) {
v = parent[k][v];
}
}
if (u == v)
return u;
for (int k = log2_n - 1; k >= 0; k--) {
if (parent[k][u] != parent[k][v]) {
u = parent[k][u];
v = parent[k][v];
}
}
return parent[0][u];
}
};
template <typename T, typename E> struct SegmentTree {
typedef function<T(T, T)> F;
typedef function<T(T, E)> G;
int n;
F f;
G g;
T d1;
E d0;
vector<T> dat;
SegmentTree(){};
SegmentTree(int n_, F f, G g, T d1, vector<T> v = vector<T>())
: f(f), g(g), d1(d1) {
init(n_);
if (n_ == (int)v.size())
build(n_, v);
}
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat.clear();
dat.resize(2 * n - 1, d1);
}
void build(int n_, vector<T> v) {
for (int i = 0; i < n_; i++)
dat[i + n - 1] = v[i];
for (int i = n - 2; i >= 0; i--)
dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
}
void update(int k, E a) {
k += n - 1;
dat[k] = g(dat[k], a);
while (k > 0) {
k = (k - 1) / 2;
dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
inline T query(int a, int b) {
T vl = d1, vr = d1;
for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
if (l & 1)
vl = f(vl, dat[(l++) - 1]);
if (r & 1)
vr = f(dat[(--r) - 1], vr);
}
return f(vl, vr);
}
};
int main() {
int N;
cin >> N;
vector<ll> A(N);
REP(i, N) cin >> A[i], A[i] = -A[i];
Solutions solve;
cout << solve.LIS(A) << endl;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
#define ITR(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
constexpr ll mod = 1000000007;
ll mpow(ll x,
ll n) { // x^n(mod) ←普通にpow(x,n)では溢れてしまうため,随時mod計算
// 2分累乗法だから早い
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % mod;
x = x * x % mod;
n = n >> 1;
}
return ans;
}
ll inv_mod(ll a) { return mpow(a, mod - 2); }
bool square(ll a) {
ll n = (ll)sqrt(a);
return a == n * n;
}
int digitsum(ll N, int a) {
if (N == 0)
return 0;
int ret = 0;
ret += digitsum(N / a, a) + N % a;
return ret;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }; // xとyの最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } // xとyの最小公倍数
void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; }
vector<ll> splitint(string n, int a) {
int Len = n.length();
if (a < 0 || Len < a)
return {-1, -1};
string left, right;
if (a != 0)
left = n.substr(0, a);
if (a != Len)
right = n.substr(a);
return {stoll(left), stoll(right)};
}
class mint {
private:
ll _num, _mod;
mint set(ll num) {
_num = num;
if (_num >= 0)
_num %= _mod;
else
_num += (1 - (_num + 1) / _mod) * _mod;
return *this;
}
ll imod(ll n) { return mpow(n, _mod - 2); }
public:
mint() {
_num = 0;
_mod = mod;
}
mint(ll num) {
_mod = mod;
_num = num % mod;
}
mint(ll num, ll M) {
_mod = M;
set(num);
}
mint(const mint &cp) {
_num = cp._num;
_mod = cp._mod;
}
mint operator=(ll x) { return mint(x % _mod, _mod); }
mint operator+(ll x) { return mint(_num + (x % _mod), _mod); }
mint operator-(ll x) { return mint(_num - (x % _mod), _mod); }
mint operator*(ll x) { return mint(_num * (x % _mod), _mod); }
mint operator/(ll x) { return mint(_num * imod(x), _mod); }
mint operator+=(ll x) { return set(_num + (x % _mod)); }
mint operator-=(ll x) { return set(_num - (x % _mod)); }
mint operator*=(ll x) { return set(_num * (x % _mod)); }
mint operator/=(ll x) { return set(_num * imod(x)); }
mint operator+(mint x) { return mint(_num + x._num, _mod); }
mint operator-(mint x) { return mint(_num - x._num, _mod); }
mint operator*(mint x) { return mint(_num * x._num, _mod); }
mint operator/(mint x) { return mint(_num * imod(x._num), _mod); }
mint operator+=(mint x) { return set(_num + x._num); }
mint operator-=(mint x) { return set(_num - x._num); }
mint operator*=(mint x) { return set(_num * x._num); }
mint operator/=(mint x) { return set(_num * imod(x._num)); }
friend mint operator+(ll x, mint m) {
return mint(m._num + (x % m._mod), m._mod);
}
friend mint operator-(ll x, mint m) {
return mint(m._num - (x % m._mod), m._mod);
}
friend mint operator*(ll x, mint m) {
return mint(m._num * (x % m._mod), m._mod);
}
friend mint operator/(ll x, mint m) {
return mint(m.imod(m._num) * x, m._mod);
}
explicit operator ll() { return _num; }
explicit operator int() { return _num; }
friend ostream &operator<<(ostream &os, const mint &x) {
os << x._num;
return os;
}
friend istream &operator>>(istream &is, mint &x) {
ll val;
is >> val;
x.set(val);
return is;
}
};
class MAT {
private:
int row, col;
vector<vector<double>> _A;
MAT set(vector<vector<double>> A) {
_A = A;
return *this;
}
public:
MAT() {}
MAT(int n, int m) {
if (n < 1 || m < 0) {
cout << "err Matrix::Matrix" << endl;
exit(1);
}
row = n;
col = m ? m : n; // m=0のとき単位行列を作る
REP(i, row) {
vector<double> a(col);
_A.push_back(a);
REP(j, col) _A[i][j] = 0;
}
// 値の初期化
if (m == 0)
REP(i, n) _A[i][i] = 1.0;
}
MAT(const MAT &cp) {
_A = cp._A;
row = cp.row;
col = cp.col;
}
double *operator[](int i) { return _A[i].data(); }
MAT operator=(vector<vector<double>> x) { return set(x); }
MAT operator+(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator+" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j];
return r;
}
MAT operator-(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator-" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j];
return r;
}
MAT operator*(MAT x) {
if (col != x.row) {
cout << "err Matrix::operator*" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, x.col);
REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j];
return r;
}
MAT operator/(double a) {
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a;
return r;
}
MAT operator^(ll n) {
if (row != col) {
cout << "err Matrix::operator^" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, 0), A = *this;
while (n) {
if (n & 1)
r *= A;
A *= A;
n >>= 1;
}
return r;
}
MAT operator+=(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator+=" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j];
return set(r._A);
}
MAT operator-=(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator-=" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j];
return set(r._A);
}
MAT operator*=(MAT x) {
if (col != x.row) {
cout << "err Matrix::operator*" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, x.col);
REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j];
return set(r._A);
}
MAT operator/=(double a) {
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a;
return r;
}
friend MAT operator*(double n, MAT x) {
MAT r(x.row, x.col);
REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j];
return r;
}
friend MAT operator*(MAT x, double n) {
MAT r(x.row, x.col);
REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j];
return r;
}
explicit operator vector<vector<double>>() { return _A; }
friend ostream &operator<<(ostream &os, const MAT &x) {
REP(i, x.row) REP(j, x.col) os << x._A[i][j] << " \n"[j == x.col - 1];
return os;
}
int size_row() { return row; }
int size_col() { return col; }
MAT transpose() {
MAT r(col, row);
REP(i, col) REP(j, row) r[i][j] = _A[j][i];
return r;
}
};
class UnionFind { // UnionFind木
private:
vector<int> Parent;
public:
UnionFind(int N) {
Parent.resize(N);
REP(i, N) Parent[i] = -1;
}
int root(int A) {
if (Parent[A] < 0)
return A;
else
return Parent[A] = root(Parent[A]);
}
int size(int A) { return -Parent[root(A)]; }
bool connect(int A, int B) {
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
class Factorial { //階乗とその逆元を求めて計算に利用するクラス
private:
vector<ll> fac;
vector<ll> ifac;
public:
Factorial(ll N) {
fac.push_back(1);
REP(i, N) fac.push_back(fac[i] * (i + 1) % mod);
ifac.resize(N + 1);
ifac[N] = inv_mod(fac[N]);
REP(i, N) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
}
ll fact(ll a) { return fac[a]; }
ll ifact(ll a) { return ifac[a]; }
ll cmb(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0 || b < 0)
return 0;
ll tmp = ifact(a - b) * ifact(b) % mod;
return tmp * fac[a] % mod;
}
ll per(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0 || b < 0)
return 0;
return fac[a] * ifac[a - b] % mod;
}
};
class SOSU {
private:
vector<ll> Prime_Number;
public:
SOSU(int N) {
set<ll> arr;
REP(i, N - 1) arr.insert(i + 2);
while (int n = *arr.begin()) {
if (n > sqrt(N))
break;
Prime_Number.push_back(n);
rep(i, 1, N / n + 1) arr.erase(n * i);
}
ITR(itr, arr) Prime_Number.push_back(*itr);
}
ll operator[](int i) { return Prime_Number[i]; }
int count() { return Prime_Number.size(); }
bool isPrime(int q) { return binary_search(All(Prime_Number), q); }
};
struct Solutions {
ll napsack(int kinds, int MAX_W, const vl weight, const vl cost) {
vector<vector<ll>> dp(kinds + 1, vector<ll>(MAX_W + 1, 0));
REP(i, kinds) REP(j, MAX_W + 1) {
if (j < weight[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + cost[i]);
}
return dp[kinds][MAX_W];
}
ll unlimited_napsack(int kinds, int MAX_W, const vl weight, const vl cost) {
vector<vector<ll>> dp(kinds + 1, vector<ll>(MAX_W + 1, 0));
REP(i, kinds) REP(j, MAX_W + 1) {
if (j < weight[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - weight[i]] + cost[i]);
}
return dp[kinds][MAX_W];
}
ll Partition_Func(int n, int k) {
vector<vector<ll>> dp(k + 1, vector<ll>(n + 1, 0));
dp[0][0] = 1;
rep(i, 1, k + 1) REP(j, n + 1) {
if (j - i >= 0)
dp[i][j] = (dp[i][j - i] + dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
return dp[k][n];
}
int LCS(string s, string t) {
int n = s.length(), m = s.length();
vector<vector<int>> dp(n + 1, vector<int>(m + 1));
REP(i, n) REP(j, m) {
if (s[i] == t[j])
dp[i + 1][j + 1] = dp[i][j] + 1;
else
dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
}
return dp[n][m];
}
int LIS(const vector<ll> a) {
int n = a.size();
ll INF = 1 << 28;
vector<ll> dp(n + 1, INF);
REP(i, n) * upper_bound(All(dp), a[i]) = a[i];
int k = lower_bound(All(dp), INF) - dp.begin();
return k;
}
};
struct edge {
int from;
int to;
ll cost;
void push(int a, int b, int c) {
from = a;
to = b;
cost = c;
}
bool operator<(const edge &y) const {
if (cost != y.cost)
return cost < y.cost;
else if (to != y.to)
return to < y.to;
else
return from < y.from;
}
bool operator>(const edge &y) const {
if (cost != y.cost)
return cost > y.cost;
else if (to != y.to)
return to > y.to;
else
return from > y.from;
}
bool operator==(const edge &y) const { return *this == y; }
};
class lca {
public:
const int n = 0;
const int log2_n = 0;
std::vector<std::vector<int>> parent;
std::vector<int> depth;
lca() {}
lca(const Graph &g, int root)
: n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)),
depth(n) {
dfs(g, root, -1, 0);
for (int k = 0; k + 1 < log2_n; k++) {
for (int v = 0; v < (int)g.size(); v++) {
if (parent[k][v] < 0)
parent[k + 1][v] = -1;
else
parent[k + 1][v] = parent[k][parent[k][v]];
}
}
}
void dfs(const Graph &g, int v, int p, int d) {
parent[0][v] = p;
depth[v] = d;
REP(j, g[v].size()) {
if (g[v][j] != p)
dfs(g, g[v][j], v, d + 1);
}
}
int get(int u, int v) {
if (depth[u] > depth[v])
std::swap(u, v);
for (int k = 0; k < log2_n; k++) {
if ((depth[v] - depth[u]) >> k & 1) {
v = parent[k][v];
}
}
if (u == v)
return u;
for (int k = log2_n - 1; k >= 0; k--) {
if (parent[k][u] != parent[k][v]) {
u = parent[k][u];
v = parent[k][v];
}
}
return parent[0][u];
}
};
template <typename T, typename E> struct SegmentTree {
typedef function<T(T, T)> F;
typedef function<T(T, E)> G;
int n;
F f;
G g;
T d1;
E d0;
vector<T> dat;
SegmentTree(){};
SegmentTree(int n_, F f, G g, T d1, vector<T> v = vector<T>())
: f(f), g(g), d1(d1) {
init(n_);
if (n_ == (int)v.size())
build(n_, v);
}
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat.clear();
dat.resize(2 * n - 1, d1);
}
void build(int n_, vector<T> v) {
for (int i = 0; i < n_; i++)
dat[i + n - 1] = v[i];
for (int i = n - 2; i >= 0; i--)
dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
}
void update(int k, E a) {
k += n - 1;
dat[k] = g(dat[k], a);
while (k > 0) {
k = (k - 1) / 2;
dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
inline T query(int a, int b) {
T vl = d1, vr = d1;
for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
if (l & 1)
vl = f(vl, dat[(l++) - 1]);
if (r & 1)
vr = f(dat[(--r) - 1], vr);
}
return f(vl, vr);
}
};
int main() {
int N;
cin >> N;
vector<ll> A(N);
REP(i, N) cin >> A[i], A[i] = -A[i];
Solutions solve;
cout << solve.LIS(A) << endl;
} | [
"assignment.variable.change",
"identifier.change",
"call.function.change",
"expression.operation.binary.change"
] | 781,421 | 781,422 | u203033720 | cpp |
p02973 | #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD=998244353;
const long long LINF = 1e18;
using namespace std;
#define int long long
#define fin \
{ \
cout << -1 << endl; \
return 0; \
}
// template
// main
signed main() {
int N;
cin >> N;
std::vector<int> v(N);
for (int i = 0; i < N; i++)
cin >> v[i];
reverse(v.begin(), v.end());
typedef pair<int, int> P;
set<P> s;
s.insert(P(LINF, 0));
for (int i = 0; i < N; i++) {
P p = *s.upper_bound(P(v[i], 0));
if (p.first < LINF)
s.erase(p);
s.insert(P(v[i], i));
}
cout << s.size() - 1 << endl;
}
| #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD=998244353;
const long long LINF = 1e18;
using namespace std;
#define int long long
#define fin \
{ \
cout << -1 << endl; \
return 0; \
}
// template
// main
signed main() {
int N;
cin >> N;
std::vector<int> v(N);
for (int i = 0; i < N; i++)
cin >> v[i];
reverse(v.begin(), v.end());
typedef pair<int, int> P;
set<P> s;
s.insert(P(LINF, 0));
for (int i = 0; i < N; i++) {
P p = *s.upper_bound(P(v[i], i));
if (p.first < LINF)
s.erase(p);
s.insert(P(v[i], i));
}
cout << s.size() - 1 << endl;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change"
] | 781,429 | 781,430 | u942774736 | cpp |
p02973 | #include <algorithm>
#include <bits/stdc++.h>
#include <set>
using namespace std;
int main() {
int N;
cin >> N;
int A[100010] = {};
for (int i = 0; i < N; i++)
cin >> A[i];
multiset<int> S;
S.insert(-1145141919);
S.insert(1145141919);
S.insert(A[0]);
for (int i = 1; i < N; i++) {
auto it = S.lower_bound(A[i]);
it--;
if (*it == -1145141919)
S.insert(A[i]);
else {
S.insert(A[i]);
S.erase(*it);
}
}
cout << (int)S.size() - 2 << endl;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <set>
using namespace std;
int main() {
int N;
cin >> N;
int A[100010] = {};
for (int i = 0; i < N; i++)
cin >> A[i];
multiset<int> S;
S.insert(-1145141919);
S.insert(1145141919);
S.insert(A[0]);
for (int i = 1; i < N; i++) {
auto it = S.lower_bound(A[i]);
it--;
if (*it == -1145141919)
S.insert(A[i]);
else {
S.insert(A[i]);
S.erase(it);
}
}
cout << (int)S.size() - 2 << endl;
} | [
"call.arguments.change"
] | 781,431 | 781,432 | u465638326 | cpp |
p02973 | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9 + 7;
main() {
int N;
cin >> N;
vector<int> V(N), dp(N, -1);
rep(i, 0, N) cin >> V[i];
rep(i, 0, N) {
auto itr = upper_bound(dp.rbegin(), dp.rend(), V[i]);
itr--;
// cout << distance(dp.rbegin(), itr) << endl;
*itr = V[i];
}
// rep(i,0,N)cout << dp[i] << endl;
for (int i = N - 1; i >= 0; i--) {
if (dp[i] != -1) {
cout << i + 1 << endl;
return 0;
}
}
cout << N << endl;
} | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9 + 7;
main() {
int N;
cin >> N;
vector<int> V(N), dp(N, -1);
rep(i, 0, N) cin >> V[i];
rep(i, 0, N) {
auto itr = lower_bound(dp.rbegin(), dp.rend(), V[i]);
itr--;
// cout << distance(dp.rbegin(), itr) << endl;
*itr = V[i];
}
// rep(i,0,N)cout << dp[i] << endl;
for (int i = N - 1; i >= 0; i--) {
if (dp[i] != -1) {
cout << i + 1 << endl;
return 0;
}
}
cout << N << endl;
} | [
"identifier.change",
"call.function.change"
] | 781,433 | 781,434 | u157322125 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> v;
for (int i = 0; i < N; i++) {
int A;
cin >> A;
auto low = lower_bound(v.begin(), v.end(), A);
if (low == v.begin()) {
v.push_back(A);
} else {
low--;
*low = A;
}
}
cout << v.size() << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> v;
for (int i = 0; i < N; i++) {
int A;
cin >> A;
auto low = lower_bound(v.rbegin(), v.rend(), A);
if (low == v.rbegin()) {
v.push_back(A);
} else {
low--;
*low = A;
}
}
cout << v.size() << endl;
return 0;
} | [
"call.function.change",
"call.arguments.change",
"control_flow.branch.if.condition.change"
] | 781,435 | 781,436 | u904833081 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
// priority_queue<int, vector<int>, greater<int> > pq;
const int N = 300030;
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod = 1e9 + 7;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
vector<int> v;
vector<int>::iterator it;
rep(i, 0, n) {
int x;
cin >> x;
it = upper_bound(v.begin(), v.end(), x, greater<>());
if (it == v.end())
v.push_back(x);
}
cout << v.size();
}
| #include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
// priority_queue<int, vector<int>, greater<int> > pq;
const int N = 300030;
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod = 1e9 + 7;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
vector<int> v;
vector<int>::iterator it;
rep(i, 0, n) {
int x;
cin >> x;
it = upper_bound(v.begin(), v.end(), x, greater<>());
if (it == v.end())
v.push_back(x);
else
*it = x;
}
cout << v.size();
}
| [
"control_flow.branch.else_if.replace.remove",
"control_flow.branch.if.replace.add",
"assignment.add"
] | 781,437 | 781,438 | u278557567 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
long long int a[n];
for (int i = 0; i < n; i++) {
cin >> a[n];
}
vector<long long int> b(2);
b.at(0) = 1000000001;
b.at(1) = a[0] - 1;
int x;
for (int i = 0; i < n; i++) {
x = b.size();
if (b.at(x - 1) >= a[i]) {
b.push_back(a[i]);
continue;
}
for (int j = 1; j < b.size(); j++) {
if (b.at(j) < a[i]) {
b.at(j) = a[i];
break;
}
}
}
cout << b.size() - 1 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
long long int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<long long int> b(2);
b.at(0) = 1000000001;
b.at(1) = a[0] - 1;
int x;
for (int i = 0; i < n; i++) {
x = b.size();
if (b.at(x - 1) >= a[i]) {
b.push_back(a[i]);
continue;
}
for (int j = 1; j < b.size(); j++) {
if (b.at(j) < a[i]) {
b.at(j) = a[i];
break;
}
}
}
cout << b.size() - 1 << endl;
} | [
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 781,445 | 781,446 | u704064492 | cpp |
p02973 | #include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N + 1, 0);
for (int i = 1; i <= N; i++)
cin >> A[i];
map<int, int> m;
int ans = 0;
for (int i = 1; i <= N; i++) {
if (m.empty()) {
m[-A[i]]++;
ans++;
} else {
map<int, int>::iterator it = m.upper_bound(-A[i]);
if (it == m.end()) {
m[-A[i]]++;
ans++;
} else {
m[it->second]--;
if (m[it->second] == 0)
m.erase(it);
m[-A[i]]++;
}
}
}
cout << ans << endl;
} | #include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N + 1, 0);
for (int i = 1; i <= N; i++)
cin >> A[i];
map<int, int> m;
int ans = 0;
for (int i = 1; i <= N; i++) {
if (m.empty()) {
m[-A[i]]++;
ans++;
} else {
map<int, int>::iterator it = m.upper_bound(-A[i]);
if (it == m.end()) {
m[-A[i]]++;
ans++;
} else {
m[it->first]--;
if (m[it->first] == 0)
m.erase(it);
m[-A[i]]++;
}
}
}
cout << ans << endl;
} | [
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 781,458 | 781,459 | u623954643 | cpp |
p02973 | #include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i)
cin >> a[i];
for (auto &x : a)
x = -x;
set<int> dp;
for (int i = 0; i < n; ++i) {
auto it = dp.upper_bound(a[i]);
if (it == dp.end())
dp.insert(a[i]);
else {
dp.erase(it);
dp.insert(a[i]);
}
}
cout << dp.size() << endl;
} | #include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i)
cin >> a[i];
for (auto &x : a)
x = -x;
multiset<int> dp;
for (int i = 0; i < n; ++i) {
auto it = dp.upper_bound(a[i]);
if (it == dp.end())
dp.insert(a[i]);
else {
dp.erase(it);
dp.insert(a[i]);
}
}
cout << dp.size() << endl;
} | [
"variable_declaration.type.change"
] | 781,460 | 781,461 | u698760125 | cpp |
p02973 | #include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for (ll i = 0; i < N; ++i)
#define FORj(N) for (ll j = 0; j < N; ++j)
#define FORk(N) for (ll k = 0; k < N; ++k)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
// using int = ll;
ll gcd(ll m, ll n) {
if (n == 0)
return abs(m);
return (gcd(n, m % n));
}
void putYN(bool b) {
if (b) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
void swap(ll &a, ll &b) {
ll tmp = a;
a = b;
b = tmp;
}
ll combi(ll n, ll k) {
ll r = 1, rr = 1;
for (ll i = 0; i < k; ++i) {
r *= (n - i);
rr *= (i + 1);
// r %= 1000000007;
// rr %= 1000000007;
}
r /= rr;
// r %= 1000000007;
return r;
}
int main() {
ll N;
cin >> N;
vector<ll> A;
FORi(N) {
ll tmp;
cin >> tmp;
A.push_back(tmp);
}
vector<ll> aa;
FORi(N) {
ll f = false;
auto it = lower_bound(ALL(aa), A[i]);
if (it == aa.begin()) {
//新しく加える
aa.insert(it, A[i]);
} else {
auto it2 = upper_bound(ALL(aa), A[i]);
it2--;
*it2 = A[i];
}
/*if(!f){
aa.push_back(A[i]);
}*/
}
cout << aa.size() << endl;
return 0;
} | #include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for (ll i = 0; i < N; ++i)
#define FORj(N) for (ll j = 0; j < N; ++j)
#define FORk(N) for (ll k = 0; k < N; ++k)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
// using int = ll;
ll gcd(ll m, ll n) {
if (n == 0)
return abs(m);
return (gcd(n, m % n));
}
void putYN(bool b) {
if (b) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
void swap(ll &a, ll &b) {
ll tmp = a;
a = b;
b = tmp;
}
ll combi(ll n, ll k) {
ll r = 1, rr = 1;
for (ll i = 0; i < k; ++i) {
r *= (n - i);
rr *= (i + 1);
// r %= 1000000007;
// rr %= 1000000007;
}
r /= rr;
// r %= 1000000007;
return r;
}
int main() {
ll N;
cin >> N;
vector<ll> A;
FORi(N) {
ll tmp;
cin >> tmp;
A.push_back(tmp);
}
vector<ll> aa;
FORi(N) {
ll f = false;
auto it = lower_bound(ALL(aa), A[i]);
if (it == aa.begin()) {
//新しく加える
aa.insert(it, A[i]);
} else {
auto it2 = lower_bound(ALL(aa), A[i]);
it2--;
*it2 = A[i];
}
/*if(!f){
aa.push_back(A[i]);
}*/
}
// FORi(aa.size()) { cout << aa[i] << endl; }
cout << aa.size() << endl;
return 0;
} | [
"identifier.change",
"call.function.change"
] | 781,462 | 781,463 | u373586461 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
// 変数ダンプ先。coutかcerr
#define DUMPOUT cerr
// 提出時はコメントアウト
#define DEBUG_
// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {
Fast() {
std::cin.tie(0);
ios::sync_with_stdio(false);
}
} fast;
/* cpp template {{{ */
/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()
/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto &&i : n)
/* debug */
#define debug(x) \
cerr << x << " " \
<< "(L:" << __LINE__ << ")" << '\n';
/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* func */
inline bool inside(int y, int x, int H, int W) {
return y >= 0 && x >= 0 && y < H && x < W;
}
inline int in() {
int x;
cin >> x;
return x;
}
inline ll IN() {
ll x;
cin >> x;
return x;
}
inline vs split(const string &t, char c) {
vs v;
stringstream s(t);
string b;
while (getline(s, b, c))
v.eb(b);
return v;
}
template <typename T> inline bool chmin(T &a, const T &b) {
if (a > b)
a = b;
return a > b;
}
template <typename T> inline bool chmax(T &a, const T &b) {
if (a < b)
a = b;
return a < b;
}
template <typename T, typename S> inline void print(const pair<T, S> &p) {
cout << p.first << " " << p.second << endl;
}
template <typename T> inline void print(const T &x) { cout << x << '\n'; }
template <typename T, typename S>
inline void print(const vector<pair<T, S>> &v) {
for (auto &&p : v)
print(p);
}
template <typename T> inline void print(const vector<T> &v, string s = " ") {
REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");
}
// clang-format on
/* }}} */
#ifdef DEBUG_
#define DEB
#else
// DEB と打つとデバッグ時以外はコメントアウトになる
#define DEB / ## /
#endif
// 変数ダンプ用マクロ。デバッグ時以外は消滅する
// 引数はいくつでもどんな型でも可(ストリーム出力演算子があればOK)
#define dump(...) \
DEB DUMPOUT << " "; \
DUMPOUT << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" \
<< endl; \
DUMPOUT << " "; \
dump_func(__VA_ARGS__)
// デバッグ用変数ダンプ関数
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
DUMPOUT << head;
if (sizeof...(Tail) == 0) {
DUMPOUT << " ";
} else {
DUMPOUT << ", ";
}
dump_func(std::move(tail)...);
}
// vector出力
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
os << "{";
for (int i = 0; i < vec.size(); i++) {
os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
}
os << "}";
return os;
}
ll mod = 1000000007;
ll modplus(ll x, ll y) { return (x + y) % mod; }
ll modminus(ll x, ll y) { return (x - y + mod) % mod; }
ll multiply(ll x, ll y) { return (x % mod) * (y % mod) % mod; }
ll power(ll x, ll y) {
if (y == 0) {
return 1;
} else if (y == 1) {
return x % mod;
} else if (y % 2 == 0) {
ll p = power(x, y / 2);
return p * p % mod;
} else {
ll p = power(x, y / 2);
return (p * p) % mod * (x % mod) % mod;
}
}
ll divide(ll x, ll y) { return multiply(x, power(y, mod - 2)); }
ll frac[1000000];
ll invfrac[1000000];
void fracinvfrac(ll n) {
frac[0] = 1;
for (int i = 1; i <= n; i++) {
frac[i] = multiply(frac[i - 1], i);
}
invfrac[n] = divide(1, frac[n]);
for (int i = n - 1; i >= 0; i--) {
invfrac[i] = multiply(invfrac[i + 1], i + 1);
}
}
ll modcombi(ll x, ll y) {
if (y == 0) {
return 1;
} else {
return multiply(multiply(frac[x], invfrac[x - y]), invfrac[y]);
}
}
vector<vector<int>> calcNext(vector<int> A) {
int n = (int)A.size();
vector<vector<int>> res(n + 1, vector<int>(100001, n));
for (int i = n - 1; i >= 0; --i) {
for (int j = 0; j < 100001; ++j)
res[i][j] = res[i + 1][j];
res[i][A[i]] = i;
}
return res;
}
ll A[100000];
signed main() {
// 昇順に処理する
std::priority_queue<ll, // 要素の型はint
std::vector<ll>, // 内部コンテナはstd::vector
// (デフォルトのまま)
std::greater<ll> // 昇順 (デフォルトはstd::less<T>)
>
que, q2;
// while (!que.empty()) {
// std::cout << que.top() << std::endl;
// que.pop();
// }
ll N;
cin >> N;
REP(i, N) cin >> A[i];
ll m;
ll ans;
m = A[0];
ans = 1;
// que.push(A[0]);
// REPS(i, 1, N) {
// std::priority_queue<
// ll, // 要素の型はint
// std::vector<ll>, // 内部コンテナはstd::vector (デフォルトのまま)
// std::greater<ll> // 昇順 (デフォルトはstd::less<T>)
// > empty;
// swap(empty, q2);
// m = que.top();
// if (A[i] <= m) {
// ans++;
// que.push(A[i]);
// } else {
// que.pop();
// que.push(A[i]);
// }
// while(!que.empty()) {
// q2.push(que.top());
// cout << que.top() << " ";
// que.pop();
// }
// cout << endl;
// swap(que, q2);
// }
vector<ll> v;
v.pb(A[0]);
m = v[0];
ans = 1;
REPS(i, 1, N) {
m = v[0];
if (A[i] <= m) {
ans++;
v.insert(v.begin(), A[i]);
} else {
auto Iter = lower_bound(ALL(v), A[i]);
*Iter = A[i];
}
}
print(ans);
return 0;
}
// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々 | #include <bits/stdc++.h>
using namespace std;
// 変数ダンプ先。coutかcerr
#define DUMPOUT cerr
// 提出時はコメントアウト
#define DEBUG_
// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {
Fast() {
std::cin.tie(0);
ios::sync_with_stdio(false);
}
} fast;
/* cpp template {{{ */
/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()
/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto &&i : n)
/* debug */
#define debug(x) \
cerr << x << " " \
<< "(L:" << __LINE__ << ")" << '\n';
/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* func */
inline bool inside(int y, int x, int H, int W) {
return y >= 0 && x >= 0 && y < H && x < W;
}
inline int in() {
int x;
cin >> x;
return x;
}
inline ll IN() {
ll x;
cin >> x;
return x;
}
inline vs split(const string &t, char c) {
vs v;
stringstream s(t);
string b;
while (getline(s, b, c))
v.eb(b);
return v;
}
template <typename T> inline bool chmin(T &a, const T &b) {
if (a > b)
a = b;
return a > b;
}
template <typename T> inline bool chmax(T &a, const T &b) {
if (a < b)
a = b;
return a < b;
}
template <typename T, typename S> inline void print(const pair<T, S> &p) {
cout << p.first << " " << p.second << endl;
}
template <typename T> inline void print(const T &x) { cout << x << '\n'; }
template <typename T, typename S>
inline void print(const vector<pair<T, S>> &v) {
for (auto &&p : v)
print(p);
}
template <typename T> inline void print(const vector<T> &v, string s = " ") {
REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");
}
// clang-format on
/* }}} */
#ifdef DEBUG_
#define DEB
#else
// DEB と打つとデバッグ時以外はコメントアウトになる
#define DEB / ## /
#endif
// 変数ダンプ用マクロ。デバッグ時以外は消滅する
// 引数はいくつでもどんな型でも可(ストリーム出力演算子があればOK)
#define dump(...) \
DEB DUMPOUT << " "; \
DUMPOUT << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" \
<< endl; \
DUMPOUT << " "; \
dump_func(__VA_ARGS__)
// デバッグ用変数ダンプ関数
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
DUMPOUT << head;
if (sizeof...(Tail) == 0) {
DUMPOUT << " ";
} else {
DUMPOUT << ", ";
}
dump_func(std::move(tail)...);
}
// vector出力
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
os << "{";
for (int i = 0; i < vec.size(); i++) {
os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
}
os << "}";
return os;
}
ll mod = 1000000007;
ll modplus(ll x, ll y) { return (x + y) % mod; }
ll modminus(ll x, ll y) { return (x - y + mod) % mod; }
ll multiply(ll x, ll y) { return (x % mod) * (y % mod) % mod; }
ll power(ll x, ll y) {
if (y == 0) {
return 1;
} else if (y == 1) {
return x % mod;
} else if (y % 2 == 0) {
ll p = power(x, y / 2);
return p * p % mod;
} else {
ll p = power(x, y / 2);
return (p * p) % mod * (x % mod) % mod;
}
}
ll divide(ll x, ll y) { return multiply(x, power(y, mod - 2)); }
ll frac[1000000];
ll invfrac[1000000];
void fracinvfrac(ll n) {
frac[0] = 1;
for (int i = 1; i <= n; i++) {
frac[i] = multiply(frac[i - 1], i);
}
invfrac[n] = divide(1, frac[n]);
for (int i = n - 1; i >= 0; i--) {
invfrac[i] = multiply(invfrac[i + 1], i + 1);
}
}
ll modcombi(ll x, ll y) {
if (y == 0) {
return 1;
} else {
return multiply(multiply(frac[x], invfrac[x - y]), invfrac[y]);
}
}
vector<vector<int>> calcNext(vector<int> A) {
int n = (int)A.size();
vector<vector<int>> res(n + 1, vector<int>(100001, n));
for (int i = n - 1; i >= 0; --i) {
for (int j = 0; j < 100001; ++j)
res[i][j] = res[i + 1][j];
res[i][A[i]] = i;
}
return res;
}
ll A[100000];
signed main() {
// 昇順に処理する
std::priority_queue<ll, // 要素の型はint
std::vector<ll>, // 内部コンテナはstd::vector
// (デフォルトのまま)
std::greater<ll> // 昇順 (デフォルトはstd::less<T>)
>
que, q2;
// while (!que.empty()) {
// std::cout << que.top() << std::endl;
// que.pop();
// }
ll N;
cin >> N;
REP(i, N) cin >> A[i];
ll m;
ll ans;
m = A[0];
ans = 1;
// que.push(A[0]);
// REPS(i, 1, N) {
// std::priority_queue<
// ll, // 要素の型はint
// std::vector<ll>, // 内部コンテナはstd::vector (デフォルトのまま)
// std::greater<ll> // 昇順 (デフォルトはstd::less<T>)
// > empty;
// swap(empty, q2);
// m = que.top();
// if (A[i] <= m) {
// ans++;
// que.push(A[i]);
// } else {
// que.pop();
// que.push(A[i]);
// }
// while(!que.empty()) {
// q2.push(que.top());
// cout << que.top() << " ";
// que.pop();
// }
// cout << endl;
// swap(que, q2);
// }
vector<ll> v;
v.pb(A[0]);
m = v[0];
ans = 1;
REPS(i, 1, N) {
m = v[0];
if (A[i] <= m) {
ans++;
v.insert(v.begin(), A[i]);
} else {
auto Iter = lower_bound(ALL(v), A[i]);
*(Iter - 1) = A[i];
}
}
print(ans);
return 0;
}
// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々 | [] | 781,464 | 781,465 | u545411641 | cpp |
p02973 | /*
オーダー
10**6 余裕を持って間に合う
10**7 おそらく間に合う 余裕を持って間に合う
10**8 非常にシンプルな処理でない限り厳しい おそらく間に合う
10**9 非常にシンプルな処理でない限り厳しい
logn :OK
n :10^7
nlogn :10^6
n**2 :10^4
n**3 :300
2**n :20
n! :10
// 各桁の和を計算する関数
int findSumOfDigits(int n) {
int sum = 0;
while (n > 0) { // n が 0 になるまで
sum += n % 10;
n /= 10;
}
return sum;
}
sort(a, a + N, greater<int>()); // a[0:N] を大きい順にソート
int num[110] = {0}; // バケット
for (int i = 0; i < N; ++i) {
num[d[i]]++; // d[i] が 1 個増える
}
map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
auto itr = mp.find(s[i]); // s[i] が設定されているか?
if(itr != mp.end() ) {
mp[s[i]] += 1;
}
else {
mp[s[i]] += 1 ;
}
}
stack<int> s; //intをデータとするスタックを用意
s.push(1); //{} -> {1}
printf("%d\n", s.top()); // 3
s.pop();
queue<int> que; //intをデータとするキューを用意
que.push(1); //{} -> {1}
printf("%d\n", que.front()); // 1
que.pop();
*/
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll, ll> P;
#define REP(i, n) for (long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
// int amari = 0;
// int keta = 0;
// while (n > 0) { // n が 0 になるまで
// amari += n % 2;
// if (keta%2==0)
// n /= 10;
// }
// return sum;
// }
const ll MAX_N = 1e5;
ll N;
ll h[MAX_N];
ll dp[MAX_N + 1]; // メモ化テーブル
// i番目以降の品物から重さの総和がj以下になるように選ぶ
void rec(ll i) {
if (i == 0)
dp[i] = 0;
else if (i == 1)
dp[i] = abs(h[1] - h[0]);
else
dp[i] =
min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
return;
}
vector<ll> a;
// 二分探索 drken
// https://qiita.com/drken/items/97e37dd6143e33a64c8c
// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
if (a[index] >= key)
return true;
else
return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
int right = (int)a.size(); // 「index =
// a.size()-1」が条件を満たさないこともあるので、初期値は
// a.size()
/* どんな二分探索でもここの書き方を変えずにできる! */
while (right - left > 1) {
int mid = left + (right - left) / 2;
if (isOK(mid, key))
right = mid;
else
left = mid;
}
/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている
*/
return right;
}
int main() {
// 入力
ll N;
cin >> N;
ll A[N];
for (ll i = 0; i < N; ++i)
cin >> A[i];
// 解法
REP(i, N) {
ll tmp = binary_search(A[i]);
// cout << tmp << endl;
if (tmp == 0) {
// a.pb(A[i]);
a.insert(a.begin(), A[i]);
} else {
a[tmp] = A[i];
}
}
cout << a.size() << endl;
}
| /*
オーダー
10**6 余裕を持って間に合う
10**7 おそらく間に合う 余裕を持って間に合う
10**8 非常にシンプルな処理でない限り厳しい おそらく間に合う
10**9 非常にシンプルな処理でない限り厳しい
logn :OK
n :10^7
nlogn :10^6
n**2 :10^4
n**3 :300
2**n :20
n! :10
// 各桁の和を計算する関数
int findSumOfDigits(int n) {
int sum = 0;
while (n > 0) { // n が 0 になるまで
sum += n % 10;
n /= 10;
}
return sum;
}
sort(a, a + N, greater<int>()); // a[0:N] を大きい順にソート
int num[110] = {0}; // バケット
for (int i = 0; i < N; ++i) {
num[d[i]]++; // d[i] が 1 個増える
}
map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
auto itr = mp.find(s[i]); // s[i] が設定されているか?
if(itr != mp.end() ) {
mp[s[i]] += 1;
}
else {
mp[s[i]] += 1 ;
}
}
stack<int> s; //intをデータとするスタックを用意
s.push(1); //{} -> {1}
printf("%d\n", s.top()); // 3
s.pop();
queue<int> que; //intをデータとするキューを用意
que.push(1); //{} -> {1}
printf("%d\n", que.front()); // 1
que.pop();
*/
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll, ll> P;
#define REP(i, n) for (long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
// int amari = 0;
// int keta = 0;
// while (n > 0) { // n が 0 になるまで
// amari += n % 2;
// if (keta%2==0)
// n /= 10;
// }
// return sum;
// }
const ll MAX_N = 1e5;
ll N;
ll h[MAX_N];
ll dp[MAX_N + 1]; // メモ化テーブル
// i番目以降の品物から重さの総和がj以下になるように選ぶ
void rec(ll i) {
if (i == 0)
dp[i] = 0;
else if (i == 1)
dp[i] = abs(h[1] - h[0]);
else
dp[i] =
min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
return;
}
vector<ll> a;
// 二分探索 drken
// https://qiita.com/drken/items/97e37dd6143e33a64c8c
// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
if (a[index] >= key)
return true;
else
return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
int right = (int)a.size(); // 「index =
// a.size()-1」が条件を満たさないこともあるので、初期値は
// a.size()
/* どんな二分探索でもここの書き方を変えずにできる! */
while (right - left > 1) {
int mid = left + (right - left) / 2;
if (isOK(mid, key))
right = mid;
else
left = mid;
}
/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている
*/
return right;
}
int main() {
// 入力
ll N;
cin >> N;
ll A[N];
for (ll i = 0; i < N; ++i)
cin >> A[i];
// 解法
REP(i, N) {
ll tmp = binary_search(A[i]);
// cout << tmp << endl;
if (tmp == 0) {
// a.pb(A[i]);
a.insert(a.begin(), A[i]);
} else {
a[tmp - 1] = A[i];
}
// printf("%lld : ", A[i]);
// REP(i, a.size()) printf("%lld ", a[i]);
// printf("\n");
}
cout << a.size() << endl;
}
| [
"assignment.change"
] | 781,468 | 781,469 | u757738907 | cpp |
p02973 | #include <cstdio>
#include <set>
using namespace std;
#define lb lower_bound
int N, ans;
set<int> s;
int main() {
scanf("%d", &N);
for (int i = 0, A; i < N; i++) {
scanf("%d", &A);
set<int>::iterator it = s.lb(A);
if (it == s.begin())
ans++;
else
it--, s.erase(it);
s.insert(A);
}
printf("%d\n", ans);
}
| #include <cstdio>
#include <set>
using namespace std;
#define lb lower_bound
int N, ans;
multiset<int> s;
int main() {
scanf("%d", &N);
for (int i = 0, A; i < N; i++) {
scanf("%d", &A);
set<int>::iterator it = s.lb(A);
if (it == s.begin())
ans++;
else
it--, s.erase(it);
s.insert(A);
}
printf("%d\n", ans);
}
| [
"variable_declaration.type.change"
] | 781,470 | 781,471 | u014376901 | cpp |
p02973 | /***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt)
* blesses with knowledge whom he wants."***/
/*Header file starts here*/
//#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/*Header file ends here*/
/*Macro starts here*/
#define fasterInOut \
ios::sync_with_stdio(false); \
cin.tie(0);
#define fin(in) freopen("in.txt", "r", stdin)
#define fout(out) freopen("out.txt", "w", stdout)
#define pb push_back
#define ll long long
#define lld I64d // for CF submissions
#define rh cout << "Reached Here\n"
#define inf LONG_LONG_MAX
#define neginf LONG_LONG_MIN
#define forit(it, s) \
for (__typeof((s).end()) it = (s).begin(); it != (s).end(); it++)
#define string_reverse(s) \
reverse(s.begin(), s.end()) // Vector also can be reversed with this function
#define memz(x) memset(x, 0, sizeof(x));
#define memneg(x) memset(x, -1, sizeof(x));
// Geometry & Maths
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define pi acos(-1.0)
#define negmod(ans, x, m) \
ll y = (-1 * x) % m; \
if (y == 0) \
ans = 0; \
else \
ans = m - y; // for negative mod only i.e. when x<0. Undefined when m<0
#define dis(x1, y1, x2, y2) sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
#define t_area(a, b, c, s) \
sqrt(s *(s - a) * (s - b) * (s - c)) // s= (a+b+c)/2.0
#define t_angle(a, b, c) \
acos((a * a + b * b - c * c) / \
(2 * a * b)) // returns angle C in radian. a, b, c are anti-clockwise
// formatted and side a and b form angle C
#define pointPos(x1, y1, x2, y2, x3, y3) \
((x2 - x1) * (y3 - y1)) - \
((x3 - x1) * (y2 - y1)); /*returns NEGATIVE if the Point P3 is on the \
RIGHT side of the line P1P2, otherwise returns POSITIVE in case of LEFT and \
ZERO when the point is on the line*/
#define t_areaWithPoints(x1, y1, x2, y2, x3, y3) \
abs(0.5 * \
(x1 * (y2 - y3) + x2 * (y3 - y1) + \
x3 * \
(y1 - y2))); // returns the area of a triangle formed by P1, p2, p3
// Base Conversions
#define toBin(bin, n) \
bin = bitset<8>(n).to_string() // returns a corresponding 8 bit Binary string
// 'bin' of integer 'n'
#define toOct(oct, n, ch) /*char ch[100]*/ \
sprintf(ch, "%o", n); \
oct = ch; // returns a string 'oct'(maximum 100 length): Octal represent of
// number 'n'
#define toHex(hex, n, ch) /*char ch[100]*/ \
sprintf(ch, "%x", n); \
hex = ch; // returns a string 'hex'(maximum 100 length): Hexadecimal represent
// of number 'n'
#define intToString(s, n, itos) /*stringstream itos;*/ \
itos << n; \
s = itos.str(); // converts a number 'n' to a string 's'
#define stringToint(n, s) \
stringstream stoi(s); \
stoi >> n; // converts a string 's' to a number 'n'---ONLY ONCE USABLE---
// Others
#define substring(s1, s2) \
strstr(s1.c_str(), \
s2.c_str()) // returns true if s1 contains s2 in O(n^2) complexity
#define strCharRemove(s, c) \
s.erase(remove(s.begin(), s.end(), c), \
s.end()); // Removes all character 'c' from the string 's'
#define strLastCharRemove(s) \
s.erase(s.end() - 1) // Removes last(position is given by s.end()-1) character
// form string 's'
#define vectorEraseSingle(v, pos) \
v.erase(v.begin() + pos) // Erases an element from "pos' position in zero
// based index from the vector 'v'
#define vectorEraseRange(v, spos, fpos) \
v.erase(v.begin() + spos, \
v.begin() + fpos) // Erases range inclusive spos' to
// EXCLUSIVE(without) 'fpos' from vector 'v'
#define lowerBound(v, elem) \
(lower_bound(v.begin(), v.end(), elem)) - v.begin(); /*returns the lower \
bound of 'elem' in integer(ZERO BASED INDEX), where lower bound means the \
LEFTMOST index where there is any integer which is GREATER OR EQUAL to \
'elem'.*/
#define upperBound(v, elem) \
(upper_bound(v.begin(), v.end(), elem)) - v.begin(); /*returns the upper \
bound of 'elem' in integer(ZERO BASED INDEX), where upper bound means the \
LEFTMOST index where there is any integer which is GREATER than 'elem'.*/
#define setLowerBound(st, elem) \
st.lower_bound(elem); /*returns the lower bound ITERATOR of 'elem' in the \
stl set 'st', where lower bound means the LEFTMOST index where there is any \
integer which is GREATER OR EQUAL to 'elem'.*/
#define setUpperBound(st, elem) st.upper_bound(elem));/*returns the upper bound ITERATOR of 'elem' in the stl set 'st', where upper bound means
the LEFTMOST index where there is any integer which is GREATER than 'elem'.*/
#define clearPQ(pq, type) \
pq = priority_queue<type>() /*It clears a priority queue by redeclaration*/
#define minPQ(PQ_name, type) \
priority_queue<type, vector<type>, greater<type>> \
PQ_name; /*min priority queue with built in type i.e int or long long \
etc. */
#define sortArr(arr, sz) \
sort(arr + 1, arr + (sz + 1)); /*Sorts an array from index 1 to index 'sz'*/
/*Macro ends here*/
// add vector descending sorting
using namespace std;
int main() {
fasterInOut;
ll n;
cin >> n;
ll i;
set<ll> st;
ll cnt = 0;
for (i = 1; i <= n; i++) {
ll x;
cin >> x;
auto it = setLowerBound(st, x);
if (it == st.begin()) {
st.insert(x);
cnt++;
} else {
it--;
st.erase(it);
st.insert(x);
}
}
cout << cnt << "\n";
return 0;
}
| /***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt)
* blesses with knowledge whom he wants."***/
/*Header file starts here*/
//#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/*Header file ends here*/
/*Macro starts here*/
#define fasterInOut \
ios::sync_with_stdio(false); \
cin.tie(0);
#define fin(in) freopen("in.txt", "r", stdin)
#define fout(out) freopen("out.txt", "w", stdout)
#define pb push_back
#define ll long long
#define lld I64d // for CF submissions
#define rh cout << "Reached Here\n"
#define inf LONG_LONG_MAX
#define neginf LONG_LONG_MIN
#define forit(it, s) \
for (__typeof((s).end()) it = (s).begin(); it != (s).end(); it++)
#define string_reverse(s) \
reverse(s.begin(), s.end()) // Vector also can be reversed with this function
#define memz(x) memset(x, 0, sizeof(x));
#define memneg(x) memset(x, -1, sizeof(x));
// Geometry & Maths
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define pi acos(-1.0)
#define negmod(ans, x, m) \
ll y = (-1 * x) % m; \
if (y == 0) \
ans = 0; \
else \
ans = m - y; // for negative mod only i.e. when x<0. Undefined when m<0
#define dis(x1, y1, x2, y2) sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
#define t_area(a, b, c, s) \
sqrt(s *(s - a) * (s - b) * (s - c)) // s= (a+b+c)/2.0
#define t_angle(a, b, c) \
acos((a * a + b * b - c * c) / \
(2 * a * b)) // returns angle C in radian. a, b, c are anti-clockwise
// formatted and side a and b form angle C
#define pointPos(x1, y1, x2, y2, x3, y3) \
((x2 - x1) * (y3 - y1)) - \
((x3 - x1) * (y2 - y1)); /*returns NEGATIVE if the Point P3 is on the \
RIGHT side of the line P1P2, otherwise returns POSITIVE in case of LEFT and \
ZERO when the point is on the line*/
#define t_areaWithPoints(x1, y1, x2, y2, x3, y3) \
abs(0.5 * \
(x1 * (y2 - y3) + x2 * (y3 - y1) + \
x3 * \
(y1 - y2))); // returns the area of a triangle formed by P1, p2, p3
// Base Conversions
#define toBin(bin, n) \
bin = bitset<8>(n).to_string() // returns a corresponding 8 bit Binary string
// 'bin' of integer 'n'
#define toOct(oct, n, ch) /*char ch[100]*/ \
sprintf(ch, "%o", n); \
oct = ch; // returns a string 'oct'(maximum 100 length): Octal represent of
// number 'n'
#define toHex(hex, n, ch) /*char ch[100]*/ \
sprintf(ch, "%x", n); \
hex = ch; // returns a string 'hex'(maximum 100 length): Hexadecimal represent
// of number 'n'
#define intToString(s, n, itos) /*stringstream itos;*/ \
itos << n; \
s = itos.str(); // converts a number 'n' to a string 's'
#define stringToint(n, s) \
stringstream stoi(s); \
stoi >> n; // converts a string 's' to a number 'n'---ONLY ONCE USABLE---
// Others
#define substring(s1, s2) \
strstr(s1.c_str(), \
s2.c_str()) // returns true if s1 contains s2 in O(n^2) complexity
#define strCharRemove(s, c) \
s.erase(remove(s.begin(), s.end(), c), \
s.end()); // Removes all character 'c' from the string 's'
#define strLastCharRemove(s) \
s.erase(s.end() - 1) // Removes last(position is given by s.end()-1) character
// form string 's'
#define vectorEraseSingle(v, pos) \
v.erase(v.begin() + pos) // Erases an element from "pos' position in zero
// based index from the vector 'v'
#define vectorEraseRange(v, spos, fpos) \
v.erase(v.begin() + spos, \
v.begin() + fpos) // Erases range inclusive spos' to
// EXCLUSIVE(without) 'fpos' from vector 'v'
#define lowerBound(v, elem) \
(lower_bound(v.begin(), v.end(), elem)) - v.begin(); /*returns the lower \
bound of 'elem' in integer(ZERO BASED INDEX), where lower bound means the \
LEFTMOST index where there is any integer which is GREATER OR EQUAL to \
'elem'.*/
#define upperBound(v, elem) \
(upper_bound(v.begin(), v.end(), elem)) - v.begin(); /*returns the upper \
bound of 'elem' in integer(ZERO BASED INDEX), where upper bound means the \
LEFTMOST index where there is any integer which is GREATER than 'elem'.*/
#define setLowerBound(st, elem) \
st.lower_bound(elem); /*returns the lower bound ITERATOR of 'elem' in the \
stl set 'st', where lower bound means the LEFTMOST index where there is any \
integer which is GREATER OR EQUAL to 'elem'.*/
#define setUpperBound(st, elem) st.upper_bound(elem));/*returns the upper bound ITERATOR of 'elem' in the stl set 'st', where upper bound means
the LEFTMOST index where there is any integer which is GREATER than 'elem'.*/
#define clearPQ(pq, type) \
pq = priority_queue<type>() /*It clears a priority queue by redeclaration*/
#define minPQ(PQ_name, type) \
priority_queue<type, vector<type>, greater<type>> \
PQ_name; /*min priority queue with built in type i.e int or long long \
etc. */
#define sortArr(arr, sz) \
sort(arr + 1, arr + (sz + 1)); /*Sorts an array from index 1 to index 'sz'*/
/*Macro ends here*/
// add vector descending sorting
using namespace std;
int main() {
fasterInOut;
ll n;
cin >> n;
ll i;
multiset<ll> st;
ll cnt = 0;
for (i = 1; i <= n; i++) {
ll x;
cin >> x;
auto it = setLowerBound(st, x);
if (it == st.begin()) {
st.insert(x);
cnt++;
} else {
it--;
st.erase(it);
st.insert(x);
}
}
cout << cnt << "\n";
return 0;
}
| [
"variable_declaration.type.change"
] | 781,472 | 781,473 | u081421133 | cpp |
p02973 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int a[maxn];
multiset<int> st;
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (st.size() == 0) {
st.insert(a[i]);
} else {
multiset<int>::iterator iter = st.lower_bound(a[i]);
if (iter == st.begin()) {
st.insert(a[i]);
} else {
iter--;
st.erase(*iter);
st.insert(a[i]);
}
}
}
cout << st.size() << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int a[maxn];
multiset<int> st;
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (st.size() == 0) {
st.insert(a[i]);
} else {
multiset<int>::iterator iter = st.lower_bound(a[i]);
if (iter == st.begin()) {
st.insert(a[i]);
} else {
iter--;
st.erase(iter);
st.insert(a[i]);
}
}
}
cout << st.size() << endl;
return 0;
}
| [
"call.arguments.change"
] | 781,474 | 781,475 | u940054416 | cpp |
p02975 | #include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
using namespace std;
const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;
double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; }
std::istream &operator>>(std::istream &in, set<int> &o) {
int a;
in >> a;
o.insert(a);
return in;
}
std::istream &operator>>(std::istream &in, queue<int> &o) {
ll a;
in >> a;
o.push(a);
return in;
}
bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }
// ofstream outfile("log.txt");
// outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0')
// << rank << endl;
// std::cout << std::bitset<8>(9);
// const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
int main() {
int n;
cin >> n;
vector<ll> v(n);
rep(i, n) cin >> v[i];
map<ll, int> m;
for (ll l : v)
m[l]++;
if (m.find(0) != m.end() && m[0] == n) {
cout << "Yes" << endl;
ret();
}
vector<ll> keys;
for (auto e : m)
keys.push_back(e.first);
if (keys.size() == 2 && keys[0] == 0 && m[0] == n / 3 * 2) {
cout << "Yes" << endl;
ret();
}
if (keys.size() == 3 && m[keys[0]] * 3 == n && m[keys[1]] * 3 == n &&
m[keys[2]] * 3 == n && (keys[0] ^ keys[1] ^ keys[2]) == 0) {
cout << "Yes" << endl;
ret();
}
cout << "No" << endl;
}
| #include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
using namespace std;
const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;
double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; }
std::istream &operator>>(std::istream &in, set<int> &o) {
int a;
in >> a;
o.insert(a);
return in;
}
std::istream &operator>>(std::istream &in, queue<int> &o) {
ll a;
in >> a;
o.push(a);
return in;
}
bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }
// ofstream outfile("log.txt");
// outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0')
// << rank << endl;
// std::cout << std::bitset<8>(9);
// const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
int main() {
int n;
cin >> n;
vector<ll> v(n);
rep(i, n) cin >> v[i];
map<ll, int> m;
for (ll l : v)
m[l]++;
if (m.find(0) != m.end() && m[0] == n) {
cout << "Yes" << endl;
ret();
}
vector<ll> keys;
for (auto e : m)
keys.push_back(e.first);
if (keys.size() == 2 && keys[0] == 0 && m[0] * 3 == n) {
cout << "Yes" << endl;
ret();
}
if (keys.size() == 3 && m[keys[0]] * 3 == n && m[keys[1]] * 3 == n &&
m[keys[2]] * 3 == n && (keys[0] ^ keys[1] ^ keys[2]) == 0) {
cout << "Yes" << endl;
ret();
}
cout << "No" << endl;
}
| [
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 781,479 | 781,480 | u564182781 | cpp |
p02975 | #include <bits/stdc++.h>
#include <cmath>
// using namespace boost::multiprecision;
using namespace std;
// typedef long long ll;
// typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
// typedef pair<int, int> P;
// typedef pair<ll, int> P;
// typedef pair<ll, ll> P;
// const double INF = 1e10;
// const ll INF = LONG_LONG_MAX / 100;
// const ll INF = (1ll << 31) - 1;
// const ll INF = 1e15;
// const ll MINF = LONG_LONG_MIN;
// const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
// typedef pair<int, int> P;
// typedef pair<double, double> P;
#define ret() return 0;
bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }
// ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
// ofstream outfile("log.txt");
// outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0')
// << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
// const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
int main() {
typedef unsigned long long ll;
int n;
cin >> n;
vector<ll> caps(n);
rep(i, n) cin >> caps[i];
map<ll, int> m;
for (ll c : caps)
m[c]++;
if (m.find(0) != m.end() && m[0] == n) {
cout << "Yes" << endl;
ret();
}
if (n % 3 != 0) {
cout << "No" << endl;
ret();
}
vector<ll> numbers, counts;
for (auto e : m) {
numbers.push_back(e.first);
counts.push_back(e.second);
}
if (numbers.size() == 2) {
if (numbers[0] == 0 && counts[1] == 2 * n / 3) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
ret();
}
if (numbers.size() == 3) {
if ((numbers[0] ^ numbers[1] ^ numbers[2] == 0) && counts[0] == n / 3 &&
counts[1] == n / 3 && counts[2] == n / 3) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
ret();
}
cout << "No" << endl;
}
| #include <bits/stdc++.h>
#include <cmath>
// using namespace boost::multiprecision;
using namespace std;
// typedef long long ll;
// typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
// typedef pair<int, int> P;
// typedef pair<ll, int> P;
// typedef pair<ll, ll> P;
// const double INF = 1e10;
// const ll INF = LONG_LONG_MAX / 100;
// const ll INF = (1ll << 31) - 1;
// const ll INF = 1e15;
// const ll MINF = LONG_LONG_MIN;
// const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
// typedef pair<int, int> P;
// typedef pair<double, double> P;
#define ret() return 0;
bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }
// ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
// ofstream outfile("log.txt");
// outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0')
// << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
// const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
int main() {
typedef unsigned long long ll;
int n;
cin >> n;
vector<ll> caps(n);
rep(i, n) cin >> caps[i];
map<ll, int> m;
for (ll c : caps)
m[c]++;
if (m.find(0) != m.end() && m[0] == n) {
cout << "Yes" << endl;
ret();
}
if (n % 3 != 0) {
cout << "No" << endl;
ret();
}
vector<ll> numbers, counts;
for (auto e : m) {
numbers.push_back(e.first);
counts.push_back(e.second);
}
if (numbers.size() == 2) {
if (numbers[0] == 0 && counts[1] == 2 * n / 3) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
ret();
}
if (numbers.size() == 3) {
if (((numbers[0] ^ numbers[1] ^ numbers[2]) == 0) && counts[0] == n / 3 &&
counts[1] == n / 3 && counts[2] == n / 3) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
ret();
}
cout << "No" << endl;
}
| [
"control_flow.branch.if.condition.change"
] | 781,481 | 781,482 | u564182781 | cpp |
p02975 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG
signed main() {
int N;
cin >> N;
vector<int> a(N);
rep(i, N) cin >> a[i];
map<int, int> m;
rep(i, N) m[a[i]]++;
if (m.size() == 3) {
auto b = m.begin();
auto c = next(b, 1);
auto d = next(b, 2);
int bn = (*b).second;
int cn = (*c).second;
int dn = (*d).second;
int bb = (*b).first;
int cc = (*c).first;
int dd = (*d).first;
if (bn == cn && cn == dn && (bb ^ cc) == dd) {
cout << "Yes" << endl;
return 0;
}
}
if (m[0] > 0) {
if (m.size() == 1) {
cout << "Yes" << endl;
return 0;
}
if (m.size() == 2) {
auto b = next(m.begin(), 1);
int bn = (*b).second;
int bb = (*b).first;
if (bn == m[0]) {
cout << "Yes" << endl;
return 0;
}
}
}
cout << "No" << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG
signed main() {
int N;
cin >> N;
vector<int> a(N);
rep(i, N) cin >> a[i];
map<int, int> m;
rep(i, N) m[a[i]]++;
if (m.size() == 3) {
auto b = m.begin();
auto c = next(b, 1);
auto d = next(b, 2);
int bn = (*b).second;
int cn = (*c).second;
int dn = (*d).second;
int bb = (*b).first;
int cc = (*c).first;
int dd = (*d).first;
if (bn == cn && cn == dn && (bb ^ cc) == dd) {
cout << "Yes" << endl;
return 0;
}
}
if (m[0] > 0) {
if (m.size() == 1) {
cout << "Yes" << endl;
return 0;
}
if (m.size() == 2) {
auto b = next(m.begin(), 1);
int bn = (*b).second;
int bb = (*b).first;
if (bn == 2 * m[0]) {
cout << "Yes" << endl;
return 0;
}
}
}
cout << "No" << endl;
} | [
"control_flow.branch.if.condition.change"
] | 781,485 | 781,486 | u914707890 | cpp |
p02975 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for (int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
struct Edge {
ll to, rev;
long double cap;
Edge(ll _to, long double _cap, ll _rev) {
to = _to;
cap = _cap;
rev = _rev;
}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
long double revCap) {
G[from].push_back(Edge(to, cap, (ll)G[to].size()));
if (revFlag)
G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
void solve() {
ll n;
cin >> n;
vec<ll> a(n);
map<ll, ll> mp;
REP(i, n) {
cin >> a[i];
mp[a[i]]++;
}
if (mp.size() == 1) {
if (mp.find(0) != mp.end()) {
cout << "Yes" << en;
return;
}
} else if (n % 3 == 0) {
if (mp.size() == 2) {
if (mp[0] == n / 3) {
cout << "Yes" << en;
return;
}
} else if (mp.size() == 3) {
auto it = mp.begin();
auto a = *it;
it++;
auto b = *it;
it++;
auto c = *it;
if (a.first ^ b.first == c.first and a.second == b.second and
a.second == c.second) {
cout << "Yes" << en;
return;
}
}
}
cout << "No" << en;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
// ll t;cin>>t;REP(i,t) solve();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for (int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
struct Edge {
ll to, rev;
long double cap;
Edge(ll _to, long double _cap, ll _rev) {
to = _to;
cap = _cap;
rev = _rev;
}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
long double revCap) {
G[from].push_back(Edge(to, cap, (ll)G[to].size()));
if (revFlag)
G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
void solve() {
ll n;
cin >> n;
vec<ll> a(n);
map<ll, ll> mp;
REP(i, n) {
cin >> a[i];
mp[a[i]]++;
}
if (mp.size() == 1) {
if (mp.find(0) != mp.end()) {
cout << "Yes" << en;
return;
}
} else if (n % 3 == 0) {
if (mp.size() == 2) {
if (mp[0] == n / 3) {
cout << "Yes" << en;
return;
}
} else if (mp.size() == 3) {
auto it = mp.begin();
auto a = *it;
it++;
auto b = *it;
it++;
auto c = *it;
if ((a.first ^ b.first) == c.first and a.second == b.second and
a.second == c.second) {
cout << "Yes" << en;
return;
}
}
}
cout << "No" << en;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
// ll t;cin>>t;REP(i,t) solve();
return 0;
}
| [
"control_flow.branch.if.condition.change"
] | 781,489 | 781,490 | u712993629 | cpp |
p02975 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
for (int i = 0; i < (int)v.size(); i++) {
if (i)
os << ", ";
os << v[i];
}
os << "}";
return os;
}
#ifdef LOCAL
#define cerr cout
#else
#endif
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
int main() {
map<int, int> freq;
int n;
sd(n);
for (int i = 0; i < n; i++) {
int x;
sd(x);
freq[x]++;
}
auto mn = freq.begin()->F;
int s = sz(freq);
if ((sz(freq) == 1 && mn) || sz(freq) > 3) {
printf("No\n");
return 0;
}
if (s == 1) {
printf("No\n");
return 0;
}
if (s == 2) {
if (mn != 0) {
printf("No\n");
return 0;
}
auto it = freq.begin();
int a = it->S;
it++;
int b = it->S;
if (b != 2 * a) {
printf("No\n");
return 0;
}
printf("Yes\n");
return 0;
}
auto it = freq.begin();
int a = it->S, x = it->F;
it++;
int b = it->S, y = it->F;
it++;
int c = it->S, z = it->F;
printf((a == b && b == c && c == a && (x ^ y) == z) ? "Yes\n" : "No\n");
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
for (int i = 0; i < (int)v.size(); i++) {
if (i)
os << ", ";
os << v[i];
}
os << "}";
return os;
}
#ifdef LOCAL
#define cerr cout
#else
#endif
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
int main() {
map<int, int> freq;
int n;
sd(n);
for (int i = 0; i < n; i++) {
int x;
sd(x);
freq[x]++;
}
auto mn = freq.begin()->F;
int s = sz(freq);
if ((sz(freq) == 1 && mn) || sz(freq) > 3) {
printf("No\n");
return 0;
}
if (s == 1) {
printf("Yes\n");
return 0;
}
if (s == 2) {
if (mn != 0) {
printf("No\n");
return 0;
}
auto it = freq.begin();
int a = it->S;
it++;
int b = it->S;
if (b != 2 * a) {
printf("No\n");
return 0;
}
printf("Yes\n");
return 0;
}
auto it = freq.begin();
int a = it->S, x = it->F;
it++;
int b = it->S, y = it->F;
it++;
int c = it->S, z = it->F;
printf((a == b && b == c && c == a && (x ^ y) == z) ? "Yes\n" : "No\n");
} | [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 781,491 | 781,492 | u908558278 | cpp |
p02975 | // includes
#include <bits/stdc++.h>
using namespace std;
// macros
#define ll long long
#define MOD 998244353 // 100000000 //1000000007 //
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define sz(x) ((int)(x).size())
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define itr(it, x) for (auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) \
v[x].pb(y); \
v[y].pb(x);
#define popc __builtin_popcount
#define ANS(s) \
{ \
cout << s << "\n"; \
return; \
}
// functions
template <typename T> void unique(T &c) {
c.erase(std::unique(c.begin(), c.end()), c.end());
}
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;
}
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (auto &v : vec)
is >> v;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
for (int i = 0; i < vec.size(); i++) {
os << vec[i];
if (i + 1 != vec.size())
os << " ";
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &st) {
for (auto itr = st.begin(); itr != st.end(); ++itr) {
os << *itr;
auto titr = itr;
if (++titr != st.end())
os << " ";
}
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &st) {
for (auto itr = st.begin(); itr != st.end(); ++itr) {
os << *itr;
auto titr = itr;
if (++titr != st.end())
os << " ";
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) {
for (auto itr = st.begin(); itr != st.end(); ++itr) {
os << *itr;
auto titr = itr;
if (++titr != st.end())
os << " ";
}
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &st) {
for (auto itr = st.begin(); itr != st.end(); ++itr) {
os << *itr;
auto titr = itr;
if (++titr != st.end())
os << " ";
}
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
os << "(" << itr->first << ", " << itr->second << ")";
auto titr = itr;
if (++titr != mp.end())
os << " ";
}
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp) {
for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
os << "(" << itr->first << ", " << itr->second << ")";
auto titr = itr;
if (++titr != mp.end())
os << " ";
}
return os;
}
// constants
const ll N = 1e5;
const ll M = 1e6;
const ll A = 1e7;
const ll inf = 1e9;
const long long linf = 1LL << 60;
const double er = 1e-10;
const double pi = 3.141592653589793238463;
const ll lx[4] = {0, 0, 1, -1};
const ll ly[4] = {1, -1, 0, 0};
const ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
const ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
// io
struct fast_io {
fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(20);
}
} fast_io_;
void solve() {
ll n;
cin >> n;
vector<ll> a(n);
cin >> a;
sort(all(a));
if (n % 3) {
rep(i, n) if (a[i]) ANS("No");
ANS("Yes");
}
ll f = 0;
rep(i, n) if (a[i] == 0) f++;
if (f == n)
ANS("Yes");
if (!f) {
ll z = 0, o = 0;
rep(i, n) {
if (a[i] == 0)
z++;
else
o = a[i];
}
rep(i, n) if (a[i] != 0 && a[i] != o) ANS("No");
o = n - z;
cout << (z == n / 3 && o == n / 3 * 2 ? "Yes" : "No");
} else {
ll z = 0;
map<ll, ll> mp;
rep(i, n) { mp[a[i]]++; }
if (sz(mp) != 3)
ANS("No");
itr(it, mp) {
if (it->sd != n / 3)
ANS("No");
z ^= it->ft;
}
cout << (z ? "No" : "Yes");
}
}
int main(int argc, char const *argv[]) {
ll t = 1; // cin >> t;
while (t--) {
solve();
}
return 0;
}
| // includes
#include <bits/stdc++.h>
using namespace std;
// macros
#define ll long long
#define MOD 998244353 // 100000000 //1000000007 //
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define sz(x) ((int)(x).size())
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define itr(it, x) for (auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) \
v[x].pb(y); \
v[y].pb(x);
#define popc __builtin_popcount
#define ANS(s) \
{ \
cout << s << "\n"; \
return; \
}
// functions
template <typename T> void unique(T &c) {
c.erase(std::unique(c.begin(), c.end()), c.end());
}
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;
}
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (auto &v : vec)
is >> v;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
for (int i = 0; i < vec.size(); i++) {
os << vec[i];
if (i + 1 != vec.size())
os << " ";
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &st) {
for (auto itr = st.begin(); itr != st.end(); ++itr) {
os << *itr;
auto titr = itr;
if (++titr != st.end())
os << " ";
}
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &st) {
for (auto itr = st.begin(); itr != st.end(); ++itr) {
os << *itr;
auto titr = itr;
if (++titr != st.end())
os << " ";
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) {
for (auto itr = st.begin(); itr != st.end(); ++itr) {
os << *itr;
auto titr = itr;
if (++titr != st.end())
os << " ";
}
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &st) {
for (auto itr = st.begin(); itr != st.end(); ++itr) {
os << *itr;
auto titr = itr;
if (++titr != st.end())
os << " ";
}
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
os << "(" << itr->first << ", " << itr->second << ")";
auto titr = itr;
if (++titr != mp.end())
os << " ";
}
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp) {
for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
os << "(" << itr->first << ", " << itr->second << ")";
auto titr = itr;
if (++titr != mp.end())
os << " ";
}
return os;
}
// constants
const ll N = 1e5;
const ll M = 1e6;
const ll A = 1e7;
const ll inf = 1e9;
const long long linf = 1LL << 60;
const double er = 1e-10;
const double pi = 3.141592653589793238463;
const ll lx[4] = {0, 0, 1, -1};
const ll ly[4] = {1, -1, 0, 0};
const ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
const ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
// io
struct fast_io {
fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(20);
}
} fast_io_;
void solve() {
ll n;
cin >> n;
vector<ll> a(n);
cin >> a;
sort(all(a));
if (n % 3) {
rep(i, n) if (a[i]) ANS("No");
ANS("Yes");
}
ll f = 0;
rep(i, n) if (a[i] == 0) f++;
if (f == n)
ANS("Yes");
if (f) {
ll z = 0, o = 0;
rep(i, n) {
if (a[i] == 0)
z++;
else
o = a[i];
}
rep(i, n) if (a[i] != 0 && a[i] != o) ANS("No");
o = n - z;
cout << (z == n / 3 && o == n / 3 * 2 ? "Yes" : "No");
} else {
ll z = 0;
map<ll, ll> mp;
rep(i, n) { mp[a[i]]++; } // cout << mp ;
if (sz(mp) != 3)
ANS("No");
itr(it, mp) {
if (it->sd != n / 3)
ANS("No");
z ^= it->ft;
}
cout << (z ? "No" : "Yes");
}
}
int main(int argc, char const *argv[]) {
ll t = 1; // cin >> t;
while (t--) {
solve();
}
return 0;
}
| [
"expression.operation.unary.logical.remove",
"control_flow.branch.if.condition.change"
] | 781,493 | 781,494 | u448570453 | cpp |
p02975 | #include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef vector<pairs> p;
struct Edge {
ll to, weight;
Edge(ll t, ll w) : to(t), weight(w) {}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;
ll gcd(ll a, ll b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll keta(ll N) {
int tmp{};
while (N > 0) {
tmp += (N % 10);
N /= 10;
}
N = tmp;
return N;
}
// 回文
bool kai(string S) {
bool flag = true;
for (ll i = 0; i < S.size() / 2; ++i) {
if (S[i] != S[S.size() - i - 1]) {
flag = false;
break;
}
}
return flag;
}
// ---------------------------------------------
int main() {
ll n;
cin >> n;
vector<ll> a(n);
for (ll i = 0; i < n; ++i) {
cin >> a[i];
}
ll x = a[0];
for (ll i = 1; i < n; ++i) {
x ^= a[i];
}
string ans = "NO";
if (x == 0) {
ans = "YES";
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef vector<pairs> p;
struct Edge {
ll to, weight;
Edge(ll t, ll w) : to(t), weight(w) {}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;
ll gcd(ll a, ll b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll keta(ll N) {
int tmp{};
while (N > 0) {
tmp += (N % 10);
N /= 10;
}
N = tmp;
return N;
}
// 回文
bool kai(string S) {
bool flag = true;
for (ll i = 0; i < S.size() / 2; ++i) {
if (S[i] != S[S.size() - i - 1]) {
flag = false;
break;
}
}
return flag;
}
// ---------------------------------------------
int main() {
ll n;
cin >> n;
vector<ll> a(n);
for (ll i = 0; i < n; ++i) {
cin >> a[i];
}
ll x = a[0];
for (ll i = 1; i < n; ++i) {
x ^= a[i];
}
string ans = "No";
if (x == 0) {
ans = "Yes";
}
cout << ans << endl;
return 0;
} | [
"literal.string.change",
"literal.string.case.change",
"variable_declaration.value.change",
"assignment.value.change"
] | 781,500 | 781,501 | u473023730 | cpp |
p02975 | // {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
template <class T> using V = vector<T>;
template <class T> using VV = vector<vector<T>>;
template <class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" PRId64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U> void R(T &head, U &...tail) {
_R(head);
R(tail...);
}
template <class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f\n", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T> void _W(const vector<T> &x) {
for (auto i = x.begin(); i != x.end(); _W(*i++))
if (i != x.cbegin())
putchar(' ');
}
void W() {}
template <class T, class... U> void W(const T &head, const U &...tail) {
_W(head);
putchar(sizeof...(tail) ? ' ' : '\n');
W(tail...);
}
template <class T> inline bool chmax(T &a, const T &b) {
return b > a ? a = b, true : false;
}
template <class T> inline bool chmin(T &a, const T &b) {
return b < a ? a = b, true : false;
}
template <class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) {
sort(begin(v), end(v), f);
v.resize(unique(begin(v), end(v)) - begin(v));
}
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#ifdef UNO
template <class T> void _dump(const char *s, T &&head) {
cerr << s << "=" << head << endl;
}
template <class T, class... Args>
void _dump(const char *s, T &&head, Args &&...tail) {
for (int c = 0; *s != ',' || c != 0; cerr << *s++) {
if (*s == '(' || *s == '[' || *s == '{')
c++;
if (*s == ')' || *s == ']' || *s == '}')
c--;
}
cerr << "=" << head << ", ";
_dump(s + 1, tail...);
}
#define dump(...) \
do { \
fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
_dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)
template <class Iter> ostream &_out(ostream &s, Iter b, Iter e) {
s << "[";
for (auto it = b; it != e; it++)
s << (it == b ? "" : " ") << *it;
return s << "]";
}
template <class A, class B>
ostream &operator<<(ostream &s, const pair<A, B> &p) {
return s << "(" << p.first << "," << p.second << ")";
}
template <class T> ostream &operator<<(ostream &s, const vector<T> &c) {
return _out(s, ALL(c));
}
template <class T, size_t N>
ostream &operator<<(ostream &s, const array<T, N> &c) {
return _out(s, ALL(c));
}
template <class T> ostream &operator<<(ostream &s, const set<T> &c) {
return _out(s, ALL(c));
}
template <class A, class B>
ostream &operator<<(ostream &s, const map<A, B> &c) {
return _out(s, ALL(c));
}
#else
#define dump(...)
#endif
// }}}
using VI = V<int>;
int n;
int main() {
R(n);
VI a(n);
map<int, int> cnt;
REP(i, n) R(a[i]);
REP(i, n) cnt[a[i]]++;
if (cnt[0] == n) {
cout << "Yes" << '\n';
return 0;
}
if (n % 3) {
cout << "No" << '\n';
return 0;
}
sort_uniq(a);
if (cnt[0] == n / 3 && a.size() == 2) {
cout << "Yes" << '\n';
return 0;
}
if (a.size() == 3 && a[0] ^ a[1] ^ a[2] == 0 && cnt[a[0]] == cnt[a[1]] &&
cnt[a[1]] == cnt[a[2]]) {
cout << "Yes" << '\n';
} else {
cout << "No" << '\n';
}
return 0;
}
| // {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
template <class T> using V = vector<T>;
template <class T> using VV = vector<vector<T>>;
template <class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" PRId64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U> void R(T &head, U &...tail) {
_R(head);
R(tail...);
}
template <class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f\n", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T> void _W(const vector<T> &x) {
for (auto i = x.begin(); i != x.end(); _W(*i++))
if (i != x.cbegin())
putchar(' ');
}
void W() {}
template <class T, class... U> void W(const T &head, const U &...tail) {
_W(head);
putchar(sizeof...(tail) ? ' ' : '\n');
W(tail...);
}
template <class T> inline bool chmax(T &a, const T &b) {
return b > a ? a = b, true : false;
}
template <class T> inline bool chmin(T &a, const T &b) {
return b < a ? a = b, true : false;
}
template <class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) {
sort(begin(v), end(v), f);
v.resize(unique(begin(v), end(v)) - begin(v));
}
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#ifdef UNO
template <class T> void _dump(const char *s, T &&head) {
cerr << s << "=" << head << endl;
}
template <class T, class... Args>
void _dump(const char *s, T &&head, Args &&...tail) {
for (int c = 0; *s != ',' || c != 0; cerr << *s++) {
if (*s == '(' || *s == '[' || *s == '{')
c++;
if (*s == ')' || *s == ']' || *s == '}')
c--;
}
cerr << "=" << head << ", ";
_dump(s + 1, tail...);
}
#define dump(...) \
do { \
fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
_dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)
template <class Iter> ostream &_out(ostream &s, Iter b, Iter e) {
s << "[";
for (auto it = b; it != e; it++)
s << (it == b ? "" : " ") << *it;
return s << "]";
}
template <class A, class B>
ostream &operator<<(ostream &s, const pair<A, B> &p) {
return s << "(" << p.first << "," << p.second << ")";
}
template <class T> ostream &operator<<(ostream &s, const vector<T> &c) {
return _out(s, ALL(c));
}
template <class T, size_t N>
ostream &operator<<(ostream &s, const array<T, N> &c) {
return _out(s, ALL(c));
}
template <class T> ostream &operator<<(ostream &s, const set<T> &c) {
return _out(s, ALL(c));
}
template <class A, class B>
ostream &operator<<(ostream &s, const map<A, B> &c) {
return _out(s, ALL(c));
}
#else
#define dump(...)
#endif
// }}}
using VI = V<int>;
int n;
int main() {
R(n);
VI a(n);
map<int, int> cnt;
REP(i, n) R(a[i]);
REP(i, n) cnt[a[i]]++;
if (cnt[0] == n) {
cout << "Yes" << '\n';
return 0;
}
if (n % 3) {
cout << "No" << '\n';
return 0;
}
sort_uniq(a);
if (cnt[0] == n / 3 && a.size() == 2) {
cout << "Yes" << '\n';
return 0;
}
if (a.size() == 3 && (a[0] ^ a[1] ^ a[2]) == 0 && cnt[a[0]] == cnt[a[1]] &&
cnt[a[1]] == cnt[a[2]]) {
cout << "Yes" << '\n';
} else {
cout << "No" << '\n';
}
return 0;
}
| [
"control_flow.branch.if.condition.change"
] | 781,507 | 781,508 | u385825353 | cpp |
p02975 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n);
vector<int> t;
vector<int> three;
map<int, int> mp;
rep(i, n) {
cin >> a[i];
mp[a[i]]++;
}
if (mp.size() > 3) {
cout << "No" << endl;
return 0;
}
if (mp.size() == 1) {
if (mp[0] != n) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
} else if (mp.size() == 2) {
for (auto v : mp) {
t.push_back(v.first);
}
if (mp[t[1]] == 2 * mp[0] && mp[0] != 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} else {
for (auto v : mp) {
three.push_back(v.first);
}
if (mp[three[0]] == mp[three[1]] && mp[three[1]] == mp[three[2]] &&
three[0] ^ three[1] ^ three[2] == 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n);
vector<int> t;
vector<int> three;
map<int, int> mp;
rep(i, n) {
cin >> a[i];
mp[a[i]]++;
}
if (mp.size() > 3) {
cout << "No" << endl;
return 0;
}
if (mp.size() == 1) {
if (mp[0] != n) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
} else if (mp.size() == 2) {
for (auto v : mp) {
t.push_back(v.first);
}
if (mp[t[1]] == 2 * mp[0] && mp[0] != 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} else {
for (auto v : mp) {
three.push_back(v.first);
}
if (mp[three[0]] == mp[three[1]] && mp[three[1]] == mp[three[2]] &&
(three[0] ^ three[1] ^ three[2]) == 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
| [
"control_flow.branch.if.condition.change"
] | 781,516 | 781,517 | u233586402 | cpp |
p02975 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n);
vector<int> t;
vector<int> three;
map<int, int> mp;
rep(i, n) {
cin >> a[i];
mp[a[i]]++;
}
if (mp.size() > 3) {
cout << "No" << endl;
return 0;
}
if (mp.size() == 1) {
if (mp[0] != n) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
} else if (mp.size() == 2) {
for (auto v : mp) {
t.push_back(v.first);
}
if (mp[t[1]] == 2 * mp[0] && t[0] == 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} else {
for (auto v : mp) {
three.push_back(v.first);
}
if (mp[three[0]] == mp[three[1]] && mp[three[1]] == mp[three[2]] &&
three[0] ^ three[1] ^ three[2] == 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n);
vector<int> t;
vector<int> three;
map<int, int> mp;
rep(i, n) {
cin >> a[i];
mp[a[i]]++;
}
if (mp.size() > 3) {
cout << "No" << endl;
return 0;
}
if (mp.size() == 1) {
if (mp[0] != n) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
} else if (mp.size() == 2) {
for (auto v : mp) {
t.push_back(v.first);
}
if (mp[t[1]] == 2 * mp[0] && mp[0] != 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} else {
for (auto v : mp) {
three.push_back(v.first);
}
if (mp[three[0]] == mp[three[1]] && mp[three[1]] == mp[three[2]] &&
(three[0] ^ three[1] ^ three[2]) == 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
| [
"identifier.change",
"control_flow.branch.if.condition.change",
"misc.opposites",
"expression.operator.compare.change"
] | 781,518 | 781,517 | u233586402 | cpp |
p02975 |
#include <algorithm>
#include <chrono>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define forr(i, start, count) for (int i = (start); i < (start) + (count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) \
int i; \
cin >> i
#define readll(i) \
ll i; \
cin >> i
#define readdouble(i) \
double i; \
cin >> i
#define readstring(s) \
string s; \
cin >> s
typedef long long ll;
using namespace std;
template <class T> class depth_first_search_iterator {
public:
stack<pair<T, T>> todo;
function<bool(T)> notvisited;
function<void(T)> mark_visited;
function<set<T>(T)> neighbors;
depth_first_search_iterator() {}
depth_first_search_iterator(T start, function<bool(T)> notv,
function<void(T)> mark_v,
function<set<T>(T)> neigh)
: notvisited(notv), mark_visited(mark_v), neighbors(neigh), end_(false),
current(start), prev(start) {
todo.push(make_pair(start, start));
operator++();
}
void operator++() {
end_ = true;
while (!todo.empty()) {
current = todo.top().first;
prev = todo.top().second;
todo.pop();
if (notvisited(current)) {
mark_visited(current);
for (const T x : neighbors(current)) {
todo.push(make_pair(x, current));
}
end_ = false;
break;
}
}
}
T operator*() { return current; }
T previous() { return prev; }
bool end() { return end_; }
private:
T current; // contains current node
T prev; // contains previous node
bool end_;
};
template <class T> class breadth_first_search_iterator {
public:
queue<pair<T, T>> todo;
function<bool(T)> notvisited;
function<void(T)> mark_visited;
function<set<T>(T)> neighbors;
breadth_first_search_iterator() {}
breadth_first_search_iterator(T start, function<bool(T)> notv,
function<void(T)> mark_v,
function<set<T>(T)> neigh)
: notvisited(notv), mark_visited(mark_v), neighbors(neigh), end_(false),
current(start), prev(start) {
todo.push(make_pair(start, start));
operator++();
}
void operator++() {
end_ = true;
while (!todo.empty()) {
current = todo.front().first;
prev = todo.front().second;
todo.pop();
if (notvisited(current)) {
mark_visited(current);
for (const T x : neighbors(current)) {
todo.push(make_pair(x, current));
}
end_ = false;
break;
}
}
}
T operator*() { return current; }
T previous() { return prev; }
bool end() { return end_; }
private:
T current; // current node
T prev; // previous node
bool end_;
};
template <class T> class Graph {
// allows only single connection between two vertices
public:
vector<T> vertices;
vector<set<int>> neighbors;
depth_first_search_iterator<int> dfs_iterator;
breadth_first_search_iterator<int> bfs_iterator;
vector<bool> visited;
Graph() {}
Graph(int n) {
for (int i = 0; i < n; ++i) {
AddVertex(0);
}
}
void AddVertex(T val) {
vertices.push_back(val);
neighbors.push_back(set<int>());
}
bool EdgeExists(int i, int j) {
return (neighbors[i].find(j) != neighbors[i].end());
}
void AddEdge(int i, int j) {
if (!EdgeExists(i, j)) {
neighbors[i].insert(j);
if (i != j) {
neighbors[j].insert(i);
}
}
}
T &operator[](int i) { return vertices[i]; }
void RemoveEdge(int i, int j) {
if (EdgeExists(i, j)) {
neighbors[i].erase(find(neighbors[i].begin(), neighbors[i].end(), j));
neighbors[j].erase(find(neighbors[j].begin(), neighbors[j].end(), i));
}
}
void dfs_init(int start) {
visited = vector<bool>(vertices.size(), false);
dfs_iterator = depth_first_search_iterator<int>(
start, [this](int x) { return !visited[x]; },
[this](int x) { visited[x] = true; },
[this](int x) { return neighbors[x]; });
}
void bfs_init(int start) {
visited = vector<bool>(vertices.size(), false);
bfs_iterator = breadth_first_search_iterator<int>(
start, [this](int x) { return !visited[x]; },
[this](int x) { visited[x] = true; },
[this](int x) { return neighbors[x]; });
}
void print_() {
forr(i, 0, vertices.size()) {
for (auto x : neighbors[i]) {
if (i <= x) {
cout << i << "-" << x << endl;
}
}
}
}
};
int main() {
cout.precision(17);
ll modd = 1000 * 1000 * 1000 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> rand_gen(
0, modd); // rand_gen(rng) gets the rand no
ll infinit = 10000000000000000;
// readint(test_cases);
int test_cases = 1;
forr(t, 1, test_cases) {
readint(n);
map<int, int> a;
forr(i, 0, n) {
readint(kk);
a[kk]++;
}
if (a.size() > 3) {
cout << "No" << endl;
}
if (a.size() == 3) {
int a1 = a.begin()->first, a2 = next(a.begin())->first,
a3 = next(a.begin(), 2)->first;
int c1 = a.begin()->second, c2 = next(a.begin())->second,
c3 = next(a.begin(), 2)->second;
if ((c1 != c2) || (c2 != c3) || (c3 != c1)) {
cout << "No" << endl;
break;
}
if ((a1 ^ a2 == a3) || (a2 ^ a3 == a1) || (a3 ^ a1 == a2)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
if (a.size() == 2) {
int a1 = a.begin()->first;
int c1 = a.begin()->second, c2 = next(a.begin())->second;
if ((2 * c1 == c2) && (a1 == 0)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
if (a.size() == 1) {
int a1 = a.begin()->first;
if (a1 == 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
return 0;
} |
#include <algorithm>
#include <chrono>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define forr(i, start, count) for (int i = (start); i < (start) + (count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) \
int i; \
cin >> i
#define readll(i) \
ll i; \
cin >> i
#define readdouble(i) \
double i; \
cin >> i
#define readstring(s) \
string s; \
cin >> s
typedef long long ll;
using namespace std;
template <class T> class depth_first_search_iterator {
public:
stack<pair<T, T>> todo;
function<bool(T)> notvisited;
function<void(T)> mark_visited;
function<set<T>(T)> neighbors;
depth_first_search_iterator() {}
depth_first_search_iterator(T start, function<bool(T)> notv,
function<void(T)> mark_v,
function<set<T>(T)> neigh)
: notvisited(notv), mark_visited(mark_v), neighbors(neigh), end_(false),
current(start), prev(start) {
todo.push(make_pair(start, start));
operator++();
}
void operator++() {
end_ = true;
while (!todo.empty()) {
current = todo.top().first;
prev = todo.top().second;
todo.pop();
if (notvisited(current)) {
mark_visited(current);
for (const T x : neighbors(current)) {
todo.push(make_pair(x, current));
}
end_ = false;
break;
}
}
}
T operator*() { return current; }
T previous() { return prev; }
bool end() { return end_; }
private:
T current; // contains current node
T prev; // contains previous node
bool end_;
};
template <class T> class breadth_first_search_iterator {
public:
queue<pair<T, T>> todo;
function<bool(T)> notvisited;
function<void(T)> mark_visited;
function<set<T>(T)> neighbors;
breadth_first_search_iterator() {}
breadth_first_search_iterator(T start, function<bool(T)> notv,
function<void(T)> mark_v,
function<set<T>(T)> neigh)
: notvisited(notv), mark_visited(mark_v), neighbors(neigh), end_(false),
current(start), prev(start) {
todo.push(make_pair(start, start));
operator++();
}
void operator++() {
end_ = true;
while (!todo.empty()) {
current = todo.front().first;
prev = todo.front().second;
todo.pop();
if (notvisited(current)) {
mark_visited(current);
for (const T x : neighbors(current)) {
todo.push(make_pair(x, current));
}
end_ = false;
break;
}
}
}
T operator*() { return current; }
T previous() { return prev; }
bool end() { return end_; }
private:
T current; // current node
T prev; // previous node
bool end_;
};
template <class T> class Graph {
// allows only single connection between two vertices
public:
vector<T> vertices;
vector<set<int>> neighbors;
depth_first_search_iterator<int> dfs_iterator;
breadth_first_search_iterator<int> bfs_iterator;
vector<bool> visited;
Graph() {}
Graph(int n) {
for (int i = 0; i < n; ++i) {
AddVertex(0);
}
}
void AddVertex(T val) {
vertices.push_back(val);
neighbors.push_back(set<int>());
}
bool EdgeExists(int i, int j) {
return (neighbors[i].find(j) != neighbors[i].end());
}
void AddEdge(int i, int j) {
if (!EdgeExists(i, j)) {
neighbors[i].insert(j);
if (i != j) {
neighbors[j].insert(i);
}
}
}
T &operator[](int i) { return vertices[i]; }
void RemoveEdge(int i, int j) {
if (EdgeExists(i, j)) {
neighbors[i].erase(find(neighbors[i].begin(), neighbors[i].end(), j));
neighbors[j].erase(find(neighbors[j].begin(), neighbors[j].end(), i));
}
}
void dfs_init(int start) {
visited = vector<bool>(vertices.size(), false);
dfs_iterator = depth_first_search_iterator<int>(
start, [this](int x) { return !visited[x]; },
[this](int x) { visited[x] = true; },
[this](int x) { return neighbors[x]; });
}
void bfs_init(int start) {
visited = vector<bool>(vertices.size(), false);
bfs_iterator = breadth_first_search_iterator<int>(
start, [this](int x) { return !visited[x]; },
[this](int x) { visited[x] = true; },
[this](int x) { return neighbors[x]; });
}
void print_() {
forr(i, 0, vertices.size()) {
for (auto x : neighbors[i]) {
if (i <= x) {
cout << i << "-" << x << endl;
}
}
}
}
};
int main() {
cout.precision(17);
ll modd = 1000 * 1000 * 1000 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> rand_gen(
0, modd); // rand_gen(rng) gets the rand no
ll infinit = 10000000000000000;
// readint(test_cases);
int test_cases = 1;
forr(t, 1, test_cases) {
readint(n);
map<int, int> a;
forr(i, 0, n) {
readint(kk);
a[kk]++;
}
if (a.size() > 3) {
cout << "No" << endl;
}
if (a.size() == 3) {
int a1 = a.begin()->first, a2 = next(a.begin())->first,
a3 = next(a.begin(), 2)->first;
int c1 = a.begin()->second, c2 = next(a.begin())->second,
c3 = next(a.begin(), 2)->second;
if ((c1 != c2) || (c2 != c3) || (c3 != c1)) {
cout << "No" << endl;
break;
}
if (((a1 ^ a2) == a3) || ((a2 ^ a3) == a1) || ((a3 ^ a1) == a2)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
if (a.size() == 2) {
int a1 = a.begin()->first;
int c1 = a.begin()->second, c2 = next(a.begin())->second;
if ((2 * c1 == c2) && (a1 == 0)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
if (a.size() == 1) {
int a1 = a.begin()->first;
if (a1 == 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 781,519 | 781,520 | u405653069 | cpp |
p02975 | #include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define REPV(iter, v) \
for (auto(iter) = (v).begin(); (iter) != (v).end(); ++(iter))
#define ALL(v) (v).begin(), (v).end()
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main() {
ll N;
cin >> N;
vector<ll> a(N);
REP(i, N) { cin >> a[i]; }
bool isMake = true;
ll kind = 0;
map<ll, ll> countMap;
REP(i, N) {
if (countMap.find(a[i]) == countMap.end()) {
countMap[a[i]] = 1;
kind++;
} else {
countMap[a[i]]++;
}
if (kind >= 4) {
isMake = false;
break;
}
}
if (isMake) {
if (kind == 1) {
if (countMap[0] != N) {
isMake = false;
}
} else if (kind == 2) {
if (!(N % 3 == 0 && countMap[0] == N / 3)) {
isMake = false;
}
} else if (kind == 3) {
if (N % 3 != 0) {
isMake = false;
}
vector<ll> numV;
REPV(it, countMap) { numV.push_back(it->first); }
ll a = numV[0], b = numV[1], c = numV[2];
if (!(countMap[a] == countMap[b] && countMap[a] == countMap[c])) {
isMake = false;
}
if (a ^ b ^ c != 0) {
isMake = false;
}
}
}
string ans = isMake ? "Yes" : "No";
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define REPV(iter, v) \
for (auto(iter) = (v).begin(); (iter) != (v).end(); ++(iter))
#define ALL(v) (v).begin(), (v).end()
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main() {
ll N;
cin >> N;
vector<ll> a(N);
REP(i, N) { cin >> a[i]; }
bool isMake = true;
ll kind = 0;
map<ll, ll> countMap;
REP(i, N) {
if (countMap.find(a[i]) == countMap.end()) {
countMap[a[i]] = 1;
kind++;
} else {
countMap[a[i]]++;
}
if (kind >= 4) {
isMake = false;
break;
}
}
if (isMake) {
if (kind == 1) {
if (countMap[0] != N) {
isMake = false;
}
} else if (kind == 2) {
if (!(N % 3 == 0 && countMap[0] == N / 3)) {
isMake = false;
}
} else if (kind == 3) {
if (N % 3 != 0) {
isMake = false;
}
vector<ll> numV;
REPV(it, countMap) { numV.push_back(it->first); }
ll a = numV[0], b = numV[1], c = numV[2];
if (!(countMap[a] == countMap[b] && countMap[a] == countMap[c])) {
isMake = false;
}
if ((a ^ b) != c) {
isMake = false;
}
}
}
string ans = isMake ? "Yes" : "No";
cout << ans << endl;
}
| [
"control_flow.branch.if.condition.change",
"identifier.replace.add",
"literal.replace.remove"
] | 781,521 | 781,522 | u188706971 | cpp |
p02975 | #include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define REPV(iter, v) \
for (auto(iter) = (v).begin(); (iter) != (v).end(); ++(iter))
#define ALL(v) (v).begin(), (v).end()
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main() {
ll N;
cin >> N;
vector<ll> a(N);
REP(i, N) { cin >> a[i]; }
bool isMake = true;
ll kind = 0;
map<ll, ll> countMap;
REP(i, N) {
if (countMap.find(a[i]) == countMap.end()) {
countMap[a[i]] = 1;
kind++;
} else {
countMap[a[i]]++;
}
if (kind >= 4) {
isMake = false;
break;
}
}
if (isMake) {
if (kind == 1) {
if (countMap[0] != N) {
isMake = false;
}
} else if (kind == 2) {
if (!(N % 3 == 0 && countMap[0] == N / 3)) {
isMake = false;
}
} else if (kind == 3) {
if (N % 3 != 0) {
isMake = false;
}
vector<ll> numV;
REPV(it, countMap) { numV.push_back(it->first); }
ll a = numV[0], b = numV[1], c = numV[2];
if (!(countMap[a] == countMap[b] && countMap[a] == countMap[c])) {
isMake = false;
}
if (!(a ^ b == c)) {
isMake = false;
}
}
}
string ans = isMake ? "Yes" : "No";
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define REPV(iter, v) \
for (auto(iter) = (v).begin(); (iter) != (v).end(); ++(iter))
#define ALL(v) (v).begin(), (v).end()
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main() {
ll N;
cin >> N;
vector<ll> a(N);
REP(i, N) { cin >> a[i]; }
bool isMake = true;
ll kind = 0;
map<ll, ll> countMap;
REP(i, N) {
if (countMap.find(a[i]) == countMap.end()) {
countMap[a[i]] = 1;
kind++;
} else {
countMap[a[i]]++;
}
if (kind >= 4) {
isMake = false;
break;
}
}
if (isMake) {
if (kind == 1) {
if (countMap[0] != N) {
isMake = false;
}
} else if (kind == 2) {
if (!(N % 3 == 0 && countMap[0] == N / 3)) {
isMake = false;
}
} else if (kind == 3) {
if (N % 3 != 0) {
isMake = false;
}
vector<ll> numV;
REPV(it, countMap) { numV.push_back(it->first); }
ll a = numV[0], b = numV[1], c = numV[2];
if (!(countMap[a] == countMap[b] && countMap[a] == countMap[c])) {
isMake = false;
}
if ((a ^ b) != c) {
isMake = false;
}
}
}
string ans = isMake ? "Yes" : "No";
cout << ans << endl;
}
| [
"expression.operation.unary.logical.remove",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 781,523 | 781,522 | u188706971 | cpp |
p02975 | #include <cstdio>
#include <iostream>
#include <map>
using namespace std;
int main() {
long long n;
cin >> n;
map<long long, long long> T;
for (long long i = 0; i < n; i++) {
long long a;
cin >> a;
if (T.find(a) == T.end()) {
T[a] = 1;
} else {
T[a] += 1;
}
}
if (T.size() == 3) {
if (n % 3 == 0) {
map<long long, long long>::iterator it;
long long sum = 0;
bool flag = true;
for (it = T.begin(); it != T.end(); it++) {
sum = sum ^ it->first;
if (it->second == n / 3) {
flag = false;
}
}
if (sum == 0 and flag == true) {
printf("Yes\n");
return 0;
}
}
printf("No\n");
} else if (T.size() == 2) {
if (n % 3 == 0 and T.find(0) != T.end() and T[0] == n / 3) {
printf("Yes\n");
} else {
printf("No\n");
}
} else if (T.size() == 1) {
if (T.find(0) != T.end()) {
printf("Yes\n");
} else {
printf("No\n");
}
} else {
printf("No\n");
}
return 0;
} | #include <cstdio>
#include <iostream>
#include <map>
using namespace std;
int main() {
long long n;
cin >> n;
map<long long, long long> T;
for (long long i = 0; i < n; i++) {
long long a;
cin >> a;
if (T.find(a) == T.end()) {
T[a] = 1;
} else {
T[a] += 1;
}
}
if (T.size() == 3) {
if (n % 3 == 0) {
map<long long, long long>::iterator it;
long long sum = 0;
bool flag = true;
for (it = T.begin(); it != T.end(); it++) {
sum = sum ^ it->first;
if (it->second != n / 3) {
flag = false;
}
}
if (sum == 0 and flag == true) {
printf("Yes\n");
return 0;
}
}
printf("No\n");
} else if (T.size() == 2) {
if (n % 3 == 0 and T.find(0) != T.end() and T[0] == n / 3) {
printf("Yes\n");
} else {
printf("No\n");
}
} else if (T.size() == 1) {
if (T.find(0) != T.end()) {
printf("Yes\n");
} else {
printf("No\n");
}
} else {
printf("No\n");
}
return 0;
} | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 781,524 | 781,525 | u418879326 | cpp |
p02975 | // include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
// func
// ------------------------------------------------
int CalcSumOfDigit(int n); // 各桁の和を計算する。
int getDigit(int n); // 数字の桁数を取得する。
string upper(string str); // 英字を大文字に変換する。
string lower(string str); // 英字を小文字に変換する。
// class
// ------------------------------------------------
class Combi {
public:
Combi();
long long Combination(long long n, long long k);
long long nPk_modp(long long n, long long k, long long p);
private:
vector<vector<long long>> memo;
long long n_num;
long long k_num;
void Resize(long long n, long long k);
};
// define
// ------------------------------------------------
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repe(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define vsort(v) sort((v).begin(), (v).end())
#define rvsort(v) sort(rall((v)))
#define vi vector<int>
#define GCD(a, b) __gcd((a), (b))
#define LCM(a, b) (a) / GCD((a), (b)) * (b)
#define kiriage(a, b) ((a) + (b)-1) / (b)
const int INF = 1e9;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {
ll n;
cin >> n;
map<ll, ll> m;
rep(i, n) {
ll buf;
cin >> buf;
m[buf]++;
}
bool ans = false;
if (sz(m) > 3) {
ans = false;
} else {
if (sz(m) == 1) {
if (m.begin()->first == 0)
ans = true;
} else {
if (n % 3 == 0) {
if (sz(m) == 2) {
ll f_v = m.begin()->first;
ll f_n = m.begin()->second;
if (f_v == 0 && f_n == n / 3)
ans = true;
} else if (sz(m) == 3) {
vll v(3), num(3);
ll j = 0;
for (auto itr = m.begin(); itr != m.end(); ++itr) {
v[j] = itr->first;
num[j] = itr->second;
++j;
}
if ((num[0] == num[1] && num[1] == num[2] && num[2] == num[0]) &&
((v[0] ^ v[1]) ^ v[2] == 0))
ans = true;
}
}
}
}
if (ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
int i = 1;
while (1) {
n = n / 10;
if (n == 1)
break;
i++;
}
return i;
}
int CalcSumOfDigit(int n) {
int s = 0;
while (n) {
s += n % 10;
n = n / 10;
}
return s;
}
string upper(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (97 <= *itr && *itr <= 122) {
*itr = *itr - 32;
}
}
return str;
}
string lower(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (65 <= *itr && *itr <= 90) {
*itr = *itr + 32;
}
}
return str;
}
Combi::Combi() {
n_num = -1;
k_num = -1;
};
ll Combi::Combination(ll n, ll k) {
Resize(n, k);
ll ret;
if (memo[n][k] != 0) {
ret = memo[n][k];
} else if (n == k || k == 0) {
memo[n][k] = 1;
ret = 1;
} else {
ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
memo[n][k] = ret;
}
return ret;
}
void Combi::Resize(ll n, ll k) {
if (n_num <= n || k_num <= k) {
n_num = (n + 1) * 2;
k_num = (k + 1) * 2;
memo.resize(n_num);
for (auto itr = memo.begin(); itr != memo.end(); ++itr) {
itr->resize(k_num);
}
}
}
long long Combi::nPk_modp(long long n, long long k, long long p) {
ll ans = 1;
for (long long i = k; i <= n; i++) {
ans = (ans * i) % p;
}
return ans;
};
| // include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
// func
// ------------------------------------------------
int CalcSumOfDigit(int n); // 各桁の和を計算する。
int getDigit(int n); // 数字の桁数を取得する。
string upper(string str); // 英字を大文字に変換する。
string lower(string str); // 英字を小文字に変換する。
// class
// ------------------------------------------------
class Combi {
public:
Combi();
long long Combination(long long n, long long k);
long long nPk_modp(long long n, long long k, long long p);
private:
vector<vector<long long>> memo;
long long n_num;
long long k_num;
void Resize(long long n, long long k);
};
// define
// ------------------------------------------------
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repe(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define vsort(v) sort((v).begin(), (v).end())
#define rvsort(v) sort(rall((v)))
#define vi vector<int>
#define GCD(a, b) __gcd((a), (b))
#define LCM(a, b) (a) / GCD((a), (b)) * (b)
#define kiriage(a, b) ((a) + (b)-1) / (b)
const int INF = 1e9;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {
ll n;
cin >> n;
map<ll, ll> m;
rep(i, n) {
ll buf;
cin >> buf;
m[buf]++;
}
bool ans = false;
if (sz(m) > 3) {
ans = false;
} else {
if (sz(m) == 1) {
if (m.begin()->first == 0)
ans = true;
} else {
if (n % 3 == 0) {
if (sz(m) == 2) {
ll f_v = m.begin()->first;
ll f_n = m.begin()->second;
if (f_v == 0 && f_n == n / 3)
ans = true;
} else if (sz(m) == 3) {
vll v(3), num(3);
ll j = 0;
for (auto itr = m.begin(); itr != m.end(); ++itr) {
v[j] = itr->first;
num[j] = itr->second;
++j;
}
if ((num[0] == num[1] && num[1] == num[2] && num[2] == num[0]) &&
(((v[0] ^ v[1]) ^ v[2]) == 0)) {
ans = true;
}
}
}
}
}
if (ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
int i = 1;
while (1) {
n = n / 10;
if (n == 1)
break;
i++;
}
return i;
}
int CalcSumOfDigit(int n) {
int s = 0;
while (n) {
s += n % 10;
n = n / 10;
}
return s;
}
string upper(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (97 <= *itr && *itr <= 122) {
*itr = *itr - 32;
}
}
return str;
}
string lower(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (65 <= *itr && *itr <= 90) {
*itr = *itr + 32;
}
}
return str;
}
Combi::Combi() {
n_num = -1;
k_num = -1;
};
ll Combi::Combination(ll n, ll k) {
Resize(n, k);
ll ret;
if (memo[n][k] != 0) {
ret = memo[n][k];
} else if (n == k || k == 0) {
memo[n][k] = 1;
ret = 1;
} else {
ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
memo[n][k] = ret;
}
return ret;
}
void Combi::Resize(ll n, ll k) {
if (n_num <= n || k_num <= k) {
n_num = (n + 1) * 2;
k_num = (k + 1) * 2;
memo.resize(n_num);
for (auto itr = memo.begin(); itr != memo.end(); ++itr) {
itr->resize(k_num);
}
}
}
long long Combi::nPk_modp(long long n, long long k, long long p) {
ll ans = 1;
for (long long i = k; i <= n; i++) {
ans = (ans * i) % p;
}
return ans;
};
| [
"control_flow.branch.if.condition.change"
] | 781,529 | 781,530 | u610897920 | cpp |
p02975 | // include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
// func
// ------------------------------------------------
int CalcSumOfDigit(int n); // 各桁の和を計算する。
int getDigit(int n); // 数字の桁数を取得する。
string upper(string str); // 英字を大文字に変換する。
string lower(string str); // 英字を小文字に変換する。
// class
// ------------------------------------------------
class Combi {
public:
Combi();
long long Combination(long long n, long long k);
long long nPk_modp(long long n, long long k, long long p);
private:
vector<vector<long long>> memo;
long long n_num;
long long k_num;
void Resize(long long n, long long k);
};
// define
// ------------------------------------------------
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repe(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define vsort(v) sort((v).begin(), (v).end())
#define rvsort(v) sort(rall((v)))
#define vi vector<int>
#define GCD(a, b) __gcd((a), (b))
#define LCM(a, b) (a) / GCD((a), (b)) * (b)
#define kiriage(a, b) ((a) + (b)-1) / (b)
const int INF = 1e9;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {
ll n;
cin >> n;
map<ll, ll> m;
rep(i, n) {
ll buf;
cin >> buf;
m[buf]++;
}
bool ans = false;
if (sz(m) > 3) {
ans = false;
} else {
if (sz(m) == 1) {
if (m.begin()->first == 0)
ans = true;
} else {
if (n % 3 == 0) {
if (sz(m) == 2) {
ll f_v = m.begin()->first;
ll f_n = m.begin()->second;
if (f_v == 0 && f_n == n / 3)
ans = true;
} else if (sz(m) == 3) {
vll v(3), num(3);
ll j = 0;
for (auto itr = m.begin(); itr != m.end(); ++itr) {
v[j] = itr->first;
num[j] = itr->second;
++j;
}
if ((num[0] == num[1] && num[1] == num[2] && num[2] == num[0]) &&
(v[0] ^ v[1] ^ v[2] == 0))
ans = true;
}
}
}
}
if (ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
int i = 1;
while (1) {
n = n / 10;
if (n == 1)
break;
i++;
}
return i;
}
int CalcSumOfDigit(int n) {
int s = 0;
while (n) {
s += n % 10;
n = n / 10;
}
return s;
}
string upper(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (97 <= *itr && *itr <= 122) {
*itr = *itr - 32;
}
}
return str;
}
string lower(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (65 <= *itr && *itr <= 90) {
*itr = *itr + 32;
}
}
return str;
}
Combi::Combi() {
n_num = -1;
k_num = -1;
};
ll Combi::Combination(ll n, ll k) {
Resize(n, k);
ll ret;
if (memo[n][k] != 0) {
ret = memo[n][k];
} else if (n == k || k == 0) {
memo[n][k] = 1;
ret = 1;
} else {
ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
memo[n][k] = ret;
}
return ret;
}
void Combi::Resize(ll n, ll k) {
if (n_num <= n || k_num <= k) {
n_num = (n + 1) * 2;
k_num = (k + 1) * 2;
memo.resize(n_num);
for (auto itr = memo.begin(); itr != memo.end(); ++itr) {
itr->resize(k_num);
}
}
}
long long Combi::nPk_modp(long long n, long long k, long long p) {
ll ans = 1;
for (long long i = k; i <= n; i++) {
ans = (ans * i) % p;
}
return ans;
};
| // include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
// func
// ------------------------------------------------
int CalcSumOfDigit(int n); // 各桁の和を計算する。
int getDigit(int n); // 数字の桁数を取得する。
string upper(string str); // 英字を大文字に変換する。
string lower(string str); // 英字を小文字に変換する。
// class
// ------------------------------------------------
class Combi {
public:
Combi();
long long Combination(long long n, long long k);
long long nPk_modp(long long n, long long k, long long p);
private:
vector<vector<long long>> memo;
long long n_num;
long long k_num;
void Resize(long long n, long long k);
};
// define
// ------------------------------------------------
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repe(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define vsort(v) sort((v).begin(), (v).end())
#define rvsort(v) sort(rall((v)))
#define vi vector<int>
#define GCD(a, b) __gcd((a), (b))
#define LCM(a, b) (a) / GCD((a), (b)) * (b)
#define kiriage(a, b) ((a) + (b)-1) / (b)
const int INF = 1e9;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {
ll n;
cin >> n;
map<ll, ll> m;
rep(i, n) {
ll buf;
cin >> buf;
m[buf]++;
}
bool ans = false;
if (sz(m) > 3) {
ans = false;
} else {
if (sz(m) == 1) {
if (m.begin()->first == 0)
ans = true;
} else {
if (n % 3 == 0) {
if (sz(m) == 2) {
ll f_v = m.begin()->first;
ll f_n = m.begin()->second;
if (f_v == 0 && f_n == n / 3)
ans = true;
} else if (sz(m) == 3) {
vll v(3), num(3);
ll j = 0;
for (auto itr = m.begin(); itr != m.end(); ++itr) {
v[j] = itr->first;
num[j] = itr->second;
++j;
}
if ((num[0] == num[1] && num[1] == num[2] && num[2] == num[0]) &&
(((v[0] ^ v[1]) ^ v[2]) == 0)) {
ans = true;
}
}
}
}
}
if (ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
int i = 1;
while (1) {
n = n / 10;
if (n == 1)
break;
i++;
}
return i;
}
int CalcSumOfDigit(int n) {
int s = 0;
while (n) {
s += n % 10;
n = n / 10;
}
return s;
}
string upper(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (97 <= *itr && *itr <= 122) {
*itr = *itr - 32;
}
}
return str;
}
string lower(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (65 <= *itr && *itr <= 90) {
*itr = *itr + 32;
}
}
return str;
}
Combi::Combi() {
n_num = -1;
k_num = -1;
};
ll Combi::Combination(ll n, ll k) {
Resize(n, k);
ll ret;
if (memo[n][k] != 0) {
ret = memo[n][k];
} else if (n == k || k == 0) {
memo[n][k] = 1;
ret = 1;
} else {
ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
memo[n][k] = ret;
}
return ret;
}
void Combi::Resize(ll n, ll k) {
if (n_num <= n || k_num <= k) {
n_num = (n + 1) * 2;
k_num = (k + 1) * 2;
memo.resize(n_num);
for (auto itr = memo.begin(); itr != memo.end(); ++itr) {
itr->resize(k_num);
}
}
}
long long Combi::nPk_modp(long long n, long long k, long long p) {
ll ans = 1;
for (long long i = k; i <= n; i++) {
ans = (ans * i) % p;
}
return ans;
};
| [
"control_flow.branch.if.condition.change"
] | 781,531 | 781,530 | u610897920 | cpp |
p02975 | #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD=998244353;
const long long LINF = 1e18;
using namespace std;
#define int long long
#define finn \
{ \
cout << "No" << endl; \
return 0; \
}
#define finy \
{ \
cout << "Yes" << endl; \
return 0; \
}
// template
// main
signed main() {
int N;
cin >> N;
std::vector<int> v(N);
for (int i = 0; i < N; i++)
cin >> v[i];
sort(v.begin(), v.end());
map<int, int> m;
for (int i = 0; i < N; i++)
m[v[i]]++;
if (m.size() > 3)
finn;
if (m.size() == 1) {
if (v[0] == 0)
finy else finn;
}
std::vector<int> w(3);
int cnt = 0;
for (auto p : m)
w[cnt++] = p.first;
if (m.size() == 3) {
if (w[0] ^ w[1] != w[2])
finn;
for (auto p : m)
if (p.second * 3 != N)
finn;
finy;
}
if (v[0] != 0)
finn;
if (m[0] * 3 != N)
finn;
finy;
}
| #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD=998244353;
const long long LINF = 1e18;
using namespace std;
#define int long long
#define finn \
{ \
cout << "No" << endl; \
return 0; \
}
#define finy \
{ \
cout << "Yes" << endl; \
return 0; \
}
// template
// main
signed main() {
int N;
cin >> N;
std::vector<int> v(N);
for (int i = 0; i < N; i++)
cin >> v[i];
sort(v.begin(), v.end());
map<int, int> m;
for (int i = 0; i < N; i++)
m[v[i]]++;
if (m.size() > 3)
finn;
if (m.size() == 1) {
if (v[0] == 0)
finy else finn;
}
std::vector<int> w(3);
int cnt = 0;
for (auto p : m)
w[cnt++] = p.first;
if (m.size() == 3) {
if ((w[0] ^ w[1]) != w[2])
finn;
for (auto p : m)
if (p.second * 3 != N)
finn;
finy;
}
if (v[0] != 0)
finn;
if (m[0] * 3 != N)
finn;
finy;
}
| [
"control_flow.branch.if.condition.change"
] | 781,536 | 781,537 | u942774736 | cpp |
p02975 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, ini, n) for (int i = ini; i < n; i++)
#define _rep(i, ini, n) for (int i = ini; i >= n; i--)
#define ToEnd(a) a.begin(), a.end()
uint64_t MOD = 1000000007;
int main() {
int N;
cin >> N;
vector<int> A(N);
rep(n, 0, N) cin >> A.at(n);
map<int, int> mp;
for (auto a : A)
mp[a]++;
string ans = "No";
if (mp.size() == 1) {
if (mp.count(0))
ans = "Yes";
} else if (mp.size() == 2) {
if (N % 3 == 0) {
bool correct = true;
for (auto m : mp) {
if (m.first == 0)
if (m.second != N / 3)
correct = false;
else if (m.second != 2 * N / 3)
correct = false;
if (correct)
ans = "Yes";
}
}
} else {
if (N % 3 == 0) {
bool correct = true;
vector<int> v;
for (auto m : mp) {
v.push_back(m.first);
if (m.second != N / 3)
correct = false;
}
if ((v.at(0) ^ v.at(1)) != v.at(2) || (v.at(1) ^ v.at(2)) != v.at(0) ||
(v.at(2) ^ v.at(0)) != v.at(1))
correct = false;
if (correct)
ans = "Yes";
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, ini, n) for (int i = ini; i < n; i++)
#define _rep(i, ini, n) for (int i = ini; i >= n; i--)
#define ToEnd(a) a.begin(), a.end()
uint64_t MOD = 1000000007;
int main() {
int N;
cin >> N;
vector<int> A(N);
rep(n, 0, N) cin >> A.at(n);
map<int, int> mp;
for (auto a : A)
mp[a]++;
string ans = "No";
if (mp.size() == 1) {
if (mp.count(0))
ans = "Yes";
} else if (mp.size() == 2) {
if (N % 3 == 0) {
bool correct = true;
for (auto m : mp) {
if (m.first == 0) {
if (m.second != N / 3)
correct = false;
} else {
if (m.second != 2 * N / 3)
correct = false;
}
}
if (correct)
ans = "Yes";
}
} else {
if (N % 3 == 0) {
bool correct = true;
vector<int> v;
for (auto m : mp) {
v.push_back(m.first);
if (m.second != N / 3)
correct = false;
}
if ((v.at(0) ^ v.at(1)) != v.at(2) || (v.at(1) ^ v.at(2)) != v.at(0) ||
(v.at(2) ^ v.at(0)) != v.at(1))
correct = false;
if (correct)
ans = "Yes";
}
}
cout << ans << endl;
} | [] | 781,538 | 781,539 | u190679129 | cpp |
p02975 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
int main() {
ll N;
cin >> N;
ll flag2 = 0;
vector<ll> A(N);
REP(i, N) {
cin >> A[i];
if (A[i] == 0) {
flag2 = 1;
}
}
map<ll, ll> mp;
REP(i, N) { mp[A[i]]++; }
// for(auto z:mp){
// cout << z.first << " " << z.second << endl;
// }
ll flag = 0;
if (flag2 == 1) {
// 0が含まれる場合
if (mp.size() == 1) {
// 0だけの場合
flag = 1;
} else if (mp.size() == 2) {
// 0ともう一種類だけの場合
ll y = mp[0];
for (auto x : mp) {
if (x.first != 0 && x.second == y * 2) {
flag = 1;
}
}
}
} else {
// 0が含まれない場合
if (mp.size() == 3) {
vector<P> pr(3);
ll i = 0;
for (auto x : mp) {
pr.at(i).first = x.first;
pr.at(i).second = x.second;
i++;
}
// REP(i,3){
// cout << pr.at(i).first << " " << pr.at(i).second << endl;
// }
if (pr.at(0).second == pr.at(1).second &&
pr.at(0).second == pr.at(2).second) {
if (pr.at(0).first ^ pr.at(1).first ^ pr.at(2).first == 0) {
flag = 1;
}
}
}
}
if (flag == 1) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
// if(N%3!=0){
// if(mp.size()!=1&&mp[0]==0){
// cout << "No" << endl;
// }else{
// cout << "Yes" << endl;
// }
// }else{
// if(mp.size()!=3){
// if(mp.size()!=2){
// if(mp.size()!=1){
// cout << "No" << endl;
// }else{
// if(mp[0]!=0){
// cout << "Yes" << endl;
// }else{
// cout << "No" << endl;
// }
// }
// }else{
// vector<P> pr(2);
// int i = 0;
// for(auto x:mp){
// pr.at(i).first=x.first;
// pr.at(i).second=x.second;
// i++;
// }
// // REP(i,2){
// // cout << pr.at(i).first << " " << pr.at(i).second << endl;
// // }
// if(pr.at(0).second==pr.at(1).second*2){
// if(pr.at(0).first^pr.at(0).first==pr.at(1).first){
// cout << "Yes" << endl;
// }else{
// cout << "No" << endl;
// }
// }else if(pr.at(1).second==pr.at(0).second*2){
// if(pr.at(1).first^pr.at(1).first==pr.at(0).first){
// cout << "Yes" << endl;
// }else{
// cout << "No" << endl;
// }
// }else{
// cout << "No" << endl;
// }
// }
// }else{
// vector<P> pr(3);
// int i = 0;
// for(auto x:mp){
// pr.at(i).first=x.first;
// pr.at(i).second=x.second;
// i++;
// }
// // REP(i,3){
// // cout << pr.at(i).first << " " << pr.at(i).second << endl;
// // }
// if(pr.at(0).second!=pr.at(1).second||pr.at(0).second!=pr.at(2).second){
// cout << "No" << endl;
// }else{
// if(pr.at(0).first^pr.at(1).first==pr.at(2).first){
// cout << "Yes" << endl;
// }else{
// cout << "No" << endl;
// }
// }
// }
// }
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
int main() {
ll N;
cin >> N;
ll flag2 = 0;
vector<ll> A(N);
REP(i, N) {
cin >> A[i];
if (A[i] == 0) {
flag2 = 1;
}
}
map<ll, ll> mp;
REP(i, N) { mp[A[i]]++; }
// for(auto z:mp){
// cout << z.first << " " << z.second << endl;
// }
ll flag = 0;
if (flag2 == 1) {
// 0が含まれる場合
if (mp.size() == 1) {
// 0だけの場合
flag = 1;
} else if (mp.size() == 2) {
// 0ともう一種類だけの場合
ll y = mp[0];
for (auto x : mp) {
if (x.first != 0 && x.second == y * 2) {
flag = 1;
}
}
}
} else {
// 0が含まれない場合
if (mp.size() == 3) {
vector<P> pr(3);
ll i = 0;
for (auto x : mp) {
pr.at(i).first = x.first;
pr.at(i).second = x.second;
i++;
}
// REP(i,3){
// cout << pr.at(i).first << " " << pr.at(i).second << endl;
// }
if (pr.at(0).second == pr.at(1).second &&
pr.at(0).second == pr.at(2).second) {
if ((pr.at(0).first ^ pr.at(1).first ^ pr.at(2).first) == 0) {
flag = 1;
}
}
}
}
if (flag == 1) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
// if(N%3!=0){
// if(mp.size()!=1&&mp[0]==0){
// cout << "No" << endl;
// }else{
// cout << "Yes" << endl;
// }
// }else{
// if(mp.size()!=3){
// if(mp.size()!=2){
// if(mp.size()!=1){
// cout << "No" << endl;
// }else{
// if(mp[0]!=0){
// cout << "Yes" << endl;
// }else{
// cout << "No" << endl;
// }
// }
// }else{
// vector<P> pr(2);
// int i = 0;
// for(auto x:mp){
// pr.at(i).first=x.first;
// pr.at(i).second=x.second;
// i++;
// }
// // REP(i,2){
// // cout << pr.at(i).first << " " << pr.at(i).second << endl;
// // }
// if(pr.at(0).second==pr.at(1).second*2){
// if(pr.at(0).first^pr.at(0).first==pr.at(1).first){
// cout << "Yes" << endl;
// }else{
// cout << "No" << endl;
// }
// }else if(pr.at(1).second==pr.at(0).second*2){
// if(pr.at(1).first^pr.at(1).first==pr.at(0).first){
// cout << "Yes" << endl;
// }else{
// cout << "No" << endl;
// }
// }else{
// cout << "No" << endl;
// }
// }
// }else{
// vector<P> pr(3);
// int i = 0;
// for(auto x:mp){
// pr.at(i).first=x.first;
// pr.at(i).second=x.second;
// i++;
// }
// // REP(i,3){
// // cout << pr.at(i).first << " " << pr.at(i).second << endl;
// // }
// if(pr.at(0).second!=pr.at(1).second||pr.at(0).second!=pr.at(2).second){
// cout << "No" << endl;
// }else{
// if(pr.at(0).first^pr.at(1).first==pr.at(2).first){
// cout << "Yes" << endl;
// }else{
// cout << "No" << endl;
// }
// }
// }
// }
} | [
"control_flow.branch.if.condition.change"
] | 781,548 | 781,549 | u135626132 | cpp |
p02975 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repo(i, n) for (int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL << 61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = jou(N, P / 2);
return t * t % mod;
}
return (N * jou(N, P - 1)) % mod;
} // jou(n,mod-2)で逆元
// intの最大値2147483647 ≒ 2×10^9
// long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32; で小文字に
// cout << fixed << setprecision (20); 小数点以下20桁まで
//実行時間制約2秒では2×10^8回くらいまで計算できる
int main() {
ll n;
cin >> n;
map<ll, int> p;
int notz = 0;
;
rep(i, n) {
ll x;
cin >> x;
if (p.count(x))
p.at(x)++;
else
p[x] = 1;
if (x != 0)
notz++;
}
if (n % 3 != 0) {
cout << (notz == 0 ? "Yes" : "No") << endl;
} else if (notz == 0)
cout << "Yes" << endl;
else if (notz == 2 * n / 3 && p.size() == 2)
cout << "Yes" << endl;
else if (p.size() != 3)
cout << "No" << endl;
else {
ll now = 0;
vector<ll> q(3);
vector<ll> r(3);
for (auto x : p) {
q[now] = x.fi;
r[now] = x.se;
now++;
}
cout << ((q[0] ^ q[1] == q[2] && r[0] == r[1] && r[1] == r[2]) ? "Yes"
: "No")
<< endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repo(i, n) for (int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL << 61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = jou(N, P / 2);
return t * t % mod;
}
return (N * jou(N, P - 1)) % mod;
} // jou(n,mod-2)で逆元
// intの最大値2147483647 ≒ 2×10^9
// long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32; で小文字に
// cout << fixed << setprecision (20); 小数点以下20桁まで
//実行時間制約2秒では2×10^8回くらいまで計算できる
int main() {
ll n;
cin >> n;
map<ll, int> p;
int notz = 0;
;
rep(i, n) {
ll x;
cin >> x;
if (p.count(x))
p.at(x)++;
else
p[x] = 1;
if (x != 0)
notz++;
}
if (n % 3 != 0) {
cout << (notz == 0 ? "Yes" : "No") << endl;
} else if (notz == 0)
cout << "Yes" << endl;
else if (notz == 2 * n / 3 && p.size() == 2)
cout << "Yes" << endl;
else if (p.size() != 3)
cout << "No" << endl;
else {
ll now = 0;
vector<ll> q(3);
vector<ll> r(3);
for (auto x : p) {
q[now] = x.fi;
r[now] = x.se;
now++;
}
cout << (((q[0] ^ q[1]) == q[2] && r[0] == r[1] && r[1] == r[2]) ? "Yes"
: "No")
<< endl;
}
}
| [
"control_flow.branch.if.condition.change"
] | 781,550 | 781,551 | u604329931 | cpp |
p02975 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repo(i, n) for (int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL << 61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = jou(N, P / 2);
return t * t % mod;
}
return (N * jou(N, P - 1)) % mod;
} // jou(n,mod-2)で逆元
// intの最大値2147483647 ≒ 2×10^9
// long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32; で小文字に
// cout << fixed << setprecision (20); 小数点以下20桁まで
//実行時間制約2秒では2×10^8回くらいまで計算できる
int main() {
ll n;
cin >> n;
map<ll, int> p;
int notz = 0;
;
rep(i, n) {
ll x;
cin >> x;
if (p.count(x))
p.at(x)++;
else
p[x] = 1;
if (x != 0)
notz++;
}
if (n % 3 != 0) {
cout << (notz == 0 ? "Yes" : "No") << endl;
} else if (notz == 0)
cout << "Yes" << endl;
else if (notz == n / 3 && p.size() == 2)
cout << "Yes" << endl;
else if (p.size() != 3)
cout << "No" << endl;
else {
ll now = 0;
vector<ll> q(3);
vector<ll> r(3);
for (auto x : p) {
q[now] = x.fi;
r[now] = x.se;
now++;
}
cout << ((q[0] ^ q[1] == q[2] && r[0] == r[1] && r[1] == r[2]) ? "Yes"
: "No")
<< endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repo(i, n) for (int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL << 61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = jou(N, P / 2);
return t * t % mod;
}
return (N * jou(N, P - 1)) % mod;
} // jou(n,mod-2)で逆元
// intの最大値2147483647 ≒ 2×10^9
// long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32; で小文字に
// cout << fixed << setprecision (20); 小数点以下20桁まで
//実行時間制約2秒では2×10^8回くらいまで計算できる
int main() {
ll n;
cin >> n;
map<ll, int> p;
int notz = 0;
;
rep(i, n) {
ll x;
cin >> x;
if (p.count(x))
p.at(x)++;
else
p[x] = 1;
if (x != 0)
notz++;
}
if (n % 3 != 0) {
cout << (notz == 0 ? "Yes" : "No") << endl;
} else if (notz == 0)
cout << "Yes" << endl;
else if (notz == 2 * n / 3 && p.size() == 2)
cout << "Yes" << endl;
else if (p.size() != 3)
cout << "No" << endl;
else {
ll now = 0;
vector<ll> q(3);
vector<ll> r(3);
for (auto x : p) {
q[now] = x.fi;
r[now] = x.se;
now++;
}
cout << (((q[0] ^ q[1]) == q[2] && r[0] == r[1] && r[1] == r[2]) ? "Yes"
: "No")
<< endl;
}
}
| [
"control_flow.branch.if.condition.change"
] | 781,552 | 781,551 | u604329931 | cpp |
p02975 | // Ruthless Coding
#include <bits/stdc++.h>
#define uni(x) (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v) \
for (auto x : v) \
cout << x << ' '
#define ALL(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846
#define MP(x, y) make_pair(x, y)
#define SZ(x) int((x).size())
#define PB(x) push_back(x)
#define ld long double
#define ll long long
#define S second
#define F first
#define nl '\n'
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V> void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T> void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i : x)
cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V> void _print(T t, V... v) {
__print(t);
if (sizeof...(v))
cerr << ", ";
_print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...) \
cerr << "[" << #x << "] = ["; \
_print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;
const int N = 2e5 + 5;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
map<int, int> mp;
for (auto &x : a) {
cin >> x;
mp[x]++;
}
sort(ALL(a));
uni(a);
if (SZ(a) == 1) {
if (a[0] == 0) {
cout << "Yes";
} else {
cout << "No";
}
} else if (SZ(a) == 2) {
if (a[0] == 0 && n % 3 == 0 && mp[0] == n / 3) {
cout << "Yes";
} else {
cout << "No";
}
} else if (SZ(a) == 3 && n % 3 == 0) {
if (a[0] ^ a[1] ^ a[2] == 0) {
if (mp[a[0]] == n / 3 && mp[a[1]] == n / 3 && mp[a[2]] == n / 3) {
cout << "Yes";
} else {
cout << "No";
}
} else {
cout << "No";
}
} else {
cout << "No";
}
return 0;
}
/*
*** Most Impo.. -> check base case always
1. Overflow Check (*, +)
2. Index check (0 - based or 1 - based)
3. Check for n = 1, 2, 3, 4....
4. Corner Cases
*/ | // Ruthless Coding
#include <bits/stdc++.h>
#define uni(x) (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v) \
for (auto x : v) \
cout << x << ' '
#define ALL(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846
#define MP(x, y) make_pair(x, y)
#define SZ(x) int((x).size())
#define PB(x) push_back(x)
#define ld long double
#define ll long long
#define S second
#define F first
#define nl '\n'
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V> void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T> void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i : x)
cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V> void _print(T t, V... v) {
__print(t);
if (sizeof...(v))
cerr << ", ";
_print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...) \
cerr << "[" << #x << "] = ["; \
_print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;
const int N = 2e5 + 5;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
map<int, int> mp;
for (auto &x : a) {
cin >> x;
mp[x]++;
}
sort(ALL(a));
uni(a);
if (SZ(a) == 1) {
if (a[0] == 0) {
cout << "Yes";
} else {
cout << "No";
}
} else if (SZ(a) == 2) {
if (a[0] == 0 && n % 3 == 0 && mp[0] == n / 3) {
cout << "Yes";
} else {
cout << "No";
}
} else if (SZ(a) == 3 && n % 3 == 0) {
if ((a[0] ^ a[1] ^ a[2]) == 0) {
if (mp[a[0]] == n / 3 && mp[a[1]] == n / 3 && mp[a[2]] == n / 3) {
cout << "Yes";
} else {
cout << "No";
}
} else {
cout << "No";
}
} else {
cout << "No";
}
return 0;
}
/*
*** Most Impo.. -> check base case always
1. Overflow Check (*, +)
2. Index check (0 - based or 1 - based)
3. Check for n = 1, 2, 3, 4....
4. Corner Cases
*/ | [
"control_flow.branch.if.condition.change"
] | 781,553 | 781,554 | u048400646 | cpp |
p02975 | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
LL N;
cin >> N;
// vector<LL> a(N);
unordered_map<LL, LL> m;
for (int i = 0; i < N; i++) {
LL a;
cin >> a;
m[a]++;
}
bool flag = true;
if (m.size() > 3) {
flag = false;
} else if (m.size() == 3) {
LL t = 0;
for (auto a : m) {
t ^= a.first;
if (a.second != N / 3) {
flag = false;
}
}
if (t != 0) {
flag = false;
}
} else if (m.size() == 2) {
for (auto a : m) {
if (a.first == 0) {
if (a.second != N / 3) {
flag = false;
}
} else {
if (a.second != N / 3) {
flag = false;
}
}
}
} else {
for (auto a : m) {
if (a.first != 0)
flag = false;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
LL N;
cin >> N;
// vector<LL> a(N);
unordered_map<LL, LL> m;
for (int i = 0; i < N; i++) {
LL a;
cin >> a;
m[a]++;
}
bool flag = true;
if (m.size() > 3) {
flag = false;
} else if (m.size() == 3) {
LL t = 0;
for (auto a : m) {
t ^= a.first;
if (a.second != N / 3) {
flag = false;
}
}
if (t != 0) {
flag = false;
}
} else if (m.size() == 2) {
for (auto a : m) {
if (a.first == 0) {
if (a.second != N / 3) {
flag = false;
}
} else {
if (a.second != 2 * N / 3) {
flag = false;
}
}
}
} else {
for (auto a : m) {
if (a.first != 0)
flag = false;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 781,555 | 781,556 | u293072892 | cpp |
p02975 | #include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long
//----***型定義***----
using ll = long long;
using P = pair<int, int>;
//----***Like a Pythonista***----
#define REP(ii, jj, nn) for (ll ii = jj; ii < (nn); ii++)
#define RREP(ii, nn, jj) for (ll ii = nn; jj < ii; ii--)
#define each(i, ...) for (auto &&i : __VA_ARGS__)
#define ALL(vec) (vec).begin(), (vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__), 0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__), 0.0)
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
template <class T> inline auto max(const T &a) { return *max_element(ALL(a)); }
template <class T> inline auto min(const T &a) { return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
inline ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break
//----***入出力***---
void print() { std::cout << "\n"; }
template <class T> void print(const T &x) { std::cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &...args) {
std::cout << x << " ";
print(args...);
}
#define debug(var) \
do { \
std::cerr << #var << " ↓ " \
<< "\n"; \
view(var); \
} while (0);
#define dbg cerr << "🥺🥺🥺🥺🥺🥺" << endl;
template <typename T> void view(T e) { std::cout << e << std::endl; }
template <typename T> void view(const std::vector<T> &v) {
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
}
template <typename T> void view(const std::vector<std::vector<T>> &vv) {
for (const auto &v : vv) {
view(v);
}
}
//----***初期時読み込み***----
struct initial {
initial() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(15);
};
} initial_;
signed main() {
int N;
cin >> N;
map<int, int> mp;
int a;
REP(i, 0, N) {
cin >> a;
mp[a]++;
}
if (mp[0] == N) {
print("Yes");
re 0;
}
if (N % 3 != 0) {
print("No");
re 0;
}
vector<int> keys;
each(m, mp) {
for (int i = 0; i < m.second / (N / 3); i++) {
keys.pb(m.first);
}
}
if ((keys.size() == 3) && (keys[0] ^ keys[1] ^ keys[keys[2]] == 0)) {
print("Yes");
re 0;
}
print("No");
}
| #include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long
//----***型定義***----
using ll = long long;
using P = pair<int, int>;
//----***Like a Pythonista***----
#define REP(ii, jj, nn) for (ll ii = jj; ii < (nn); ii++)
#define RREP(ii, nn, jj) for (ll ii = nn; jj < ii; ii--)
#define each(i, ...) for (auto &&i : __VA_ARGS__)
#define ALL(vec) (vec).begin(), (vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__), 0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__), 0.0)
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
template <class T> inline auto max(const T &a) { return *max_element(ALL(a)); }
template <class T> inline auto min(const T &a) { return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
inline ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break
//----***入出力***---
void print() { std::cout << "\n"; }
template <class T> void print(const T &x) { std::cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &...args) {
std::cout << x << " ";
print(args...);
}
#define debug(var) \
do { \
std::cerr << #var << " ↓ " \
<< "\n"; \
view(var); \
} while (0);
#define dbg cerr << "🥺🥺🥺🥺🥺🥺" << endl;
template <typename T> void view(T e) { std::cout << e << std::endl; }
template <typename T> void view(const std::vector<T> &v) {
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
}
template <typename T> void view(const std::vector<std::vector<T>> &vv) {
for (const auto &v : vv) {
view(v);
}
}
//----***初期時読み込み***----
struct initial {
initial() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(15);
};
} initial_;
signed main() {
int N;
cin >> N;
map<int, int> mp;
int a;
REP(i, 0, N) {
cin >> a;
mp[a]++;
}
if (mp[0] == N) {
print("Yes");
re 0;
}
if (N % 3 != 0) {
print("No");
re 0;
}
vector<int> keys;
each(m, mp) {
for (int i = 0; i < m.second / (N / 3); i++) {
keys.pb(m.first);
}
}
if (keys.size() == 3 && (keys[0] ^ keys[1] ^ keys[2]) == 0) {
print("Yes");
re 0;
}
print("No");
}
| [
"control_flow.branch.if.condition.change"
] | 781,557 | 781,558 | u526459074 | cpp |
p02975 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n;
cin >> n;
vector<unsigned int> a(n);
rep(i, n) { cin >> a[i]; }
sort(a.begin(), a.end());
vector<unsigned int> b = a;
a.erase(unique(a.begin(), a.end()), a.end());
/*rep(i, a.size())
cout << a[i];*/
if (a.size() > 3) {
cout << "No";
return 0;
}
bool flag = false;
if (a.size() == 1) {
if (b[n - 1] == 0)
flag = true;
} else if (a.size() == 2) {
if (n % 3 != 0) {
cout << "No";
return 0;
}
if (a[0] == 0) {
if (b[n / 3 - 1] == 0 && b[n / 3] == a[1])
flag = true;
}
} else if (a.size() == 3) {
if (n % 3 != 0) {
cout << "No";
return 0;
}
// printf("%d\n", ((a[0] ^ a[1]) ^ a[2]));
if (a[0] ^ a[1] ^ a[2] == 0) {
// cout << b[n/3-1] << b[n/3] << b[2*n/3-1] << b[2*n/3] << endl;
if (b[n / 3 - 1] == a[0] && b[n / 3] == a[1] &&
b[2 * n / 3 - 1] == a[1] && b[2 * n / 3] == a[2])
flag = true;
}
}
if (flag)
cout << "Yes";
else
cout << "No";
}
| #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n;
cin >> n;
vector<unsigned int> a(n);
rep(i, n) { cin >> a[i]; }
sort(a.begin(), a.end());
vector<unsigned int> b = a;
a.erase(unique(a.begin(), a.end()), a.end());
/*rep(i, a.size())
cout << a[i];*/
if (a.size() > 3) {
cout << "No";
return 0;
}
bool flag = false;
if (a.size() == 1) {
if (b[n - 1] == 0)
flag = true;
} else if (a.size() == 2) {
if (n % 3 != 0) {
cout << "No";
return 0;
}
if (a[0] == 0) {
if (b[n / 3 - 1] == 0 && b[n / 3] == a[1])
flag = true;
}
} else if (a.size() == 3) {
if (n % 3 != 0) {
cout << "No";
return 0;
}
// printf("%d\n", ((a[0] ^ a[1]) ^ a[2]));
if (((a[0] ^ a[1]) ^ a[2]) == 0) {
// cout << b[n/3-1] << b[n/3] << b[2*n/3-1] << b[2*n/3] << endl;
if (b[n / 3 - 1] == a[0] && b[n / 3] == a[1] &&
b[2 * n / 3 - 1] == a[1] && b[2 * n / 3] == a[2])
flag = true;
}
}
if (flag)
cout << "Yes";
else
cout << "No";
}
| [
"control_flow.branch.if.condition.change"
] | 781,561 | 781,562 | u790655960 | cpp |
p02975 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) { cin >> a[i]; }
sort(a.begin(), a.end());
vector<int> b = a;
a.erase(unique(a.begin(), a.end()), a.end());
/*rep(i, a.size())
cout << a[i];*/
if (a.size() > 3) {
cout << "No";
return 0;
}
bool flag = false;
if (a.size() == 1) {
if (b[n - 1] == 0)
flag = true;
} else if (a.size() == 2) {
if (n % 3 != 0) {
cout << "No";
return 0;
}
if (a[0] == 0) {
if (b[n / 3 - 1] == 0 && b[n / 3] == a[1])
flag = true;
}
} else if (a.size() == 3) {
if (n % 3 != 0) {
cout << "No";
return 0;
}
// printf("%d\n", ((a[0] ^ a[1]) ^ a[2]));
if (a[0] ^ a[1] ^ a[2] == 0) {
// cout << b[n/3-1] << b[n/3] << b[2*n/3-1] << b[2*n/3] << endl;
if (b[n / 3 - 1] == a[0] && b[n / 3] == a[1] &&
b[2 * n / 3 - 1] == a[1] && b[2 * n / 3] == a[2])
flag = true;
}
}
if (flag)
cout << "Yes";
else
cout << "No";
}
| #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n;
cin >> n;
vector<unsigned int> a(n);
rep(i, n) { cin >> a[i]; }
sort(a.begin(), a.end());
vector<unsigned int> b = a;
a.erase(unique(a.begin(), a.end()), a.end());
/*rep(i, a.size())
cout << a[i];*/
if (a.size() > 3) {
cout << "No";
return 0;
}
bool flag = false;
if (a.size() == 1) {
if (b[n - 1] == 0)
flag = true;
} else if (a.size() == 2) {
if (n % 3 != 0) {
cout << "No";
return 0;
}
if (a[0] == 0) {
if (b[n / 3 - 1] == 0 && b[n / 3] == a[1])
flag = true;
}
} else if (a.size() == 3) {
if (n % 3 != 0) {
cout << "No";
return 0;
}
// printf("%d\n", ((a[0] ^ a[1]) ^ a[2]));
if (((a[0] ^ a[1]) ^ a[2]) == 0) {
// cout << b[n/3-1] << b[n/3] << b[2*n/3-1] << b[2*n/3] << endl;
if (b[n / 3 - 1] == a[0] && b[n / 3] == a[1] &&
b[2 * n / 3 - 1] == a[1] && b[2 * n / 3] == a[2])
flag = true;
}
}
if (flag)
cout << "Yes";
else
cout << "No";
}
| [
"variable_declaration.type.widen.change",
"control_flow.branch.if.condition.change"
] | 781,563 | 781,562 | u790655960 | cpp |
p02975 | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main() {
ll N;
cin >> N;
vector<ll> a(N);
for (ll i = 0; i < N; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
if (N % 3 == 0) {
if (a[0] == 0 && a[N / 3 - 1] == 0 && a[N / 3] == a[N - 1]) {
cout << "Yes" << endl;
return 0;
} else if (a[0] == a[N / 3 - 1] && a[N / 3] == a[2 * N / 3 - 1] &&
a[2 * N / 3] == a[N - 1] &&
a[0] ^ a[N / 3] ^ a[2 * N / 3] == 0 && a[0] != a[N / 3] &&
a[0] != a[2 * N / 3] && a[N / 3] != a[2 * N / 3]) {
cout << "Yes" << endl;
return 0;
} else {
cout << "No" << endl;
return 0;
}
} else {
if (a[0] == 0 && a[N - 1] == 0) {
cout << "Yes" << endl;
return 0;
} else {
cout << "No" << endl;
return 0;
}
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main() {
ll N;
cin >> N;
vector<ll> a(N);
for (ll i = 0; i < N; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
if (N % 3 == 0) {
if (a[0] == 0 && a[N / 3 - 1] == 0 && a[N / 3] == a[N - 1]) {
cout << "Yes" << endl;
return 0;
} else if (a[0] == a[N / 3 - 1] && a[N / 3] == a[2 * N / 3 - 1] &&
a[2 * N / 3] == a[N - 1] &&
(a[0] ^ a[N / 3] ^ a[2 * N / 3]) == 0 && a[0] != a[N / 3] &&
a[0] != a[2 * N / 3] && a[N / 3] != a[2 * N / 3]) {
cout << "Yes" << endl;
return 0;
} else {
cout << "No" << endl;
return 0;
}
} else {
if (a[0] == 0 && a[N - 1] == 0) {
cout << "Yes" << endl;
return 0;
} else {
cout << "No" << endl;
return 0;
}
}
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 781,566 | 781,567 | u378155378 | cpp |
p02975 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define rep(i, n) for (lint i = 0; i < n; i++)
#define repr(i, n) for (lint i = n - 1; i >= 0; i--)
#define repi(i, ini, n) for (lint i = ini; i < n; i++)
#define repir(i, ini, n) for (lint i = n - 1; i >= ini; i--)
#define repb(i, start, end) for (lint i = start; i <= end; i++)
#define repbr(i, start, end) for (lint i = end; i >= start; i--)
#define bit(n) (1LL << n)
#define brep(i, n) rep(i, bit(n))
#define brepi(i, ini, n) repi(i, ini, bit(n))
#define len(a) (static_cast<lint>(a.size()))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rg(v, n) v.begin(), v.begin() + n
#define rrg(v, n) v.rbegin(), v.rbegin() + n
#define ret return 0;
namespace {
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
struct xy {
lint x, y;
xy() : x(0), y(0) {}
xy(lint _x, lint _y) : x(_x), y(_y) {}
xy operator+(const xy &p) const { return xy(x + p.x, y + p.y); }
bool operator<(xy p) const {
if (y == p.y)
return x < p.x;
return y < p.y;
}
};
struct xyd {
ld x, y;
xyd() : x(0), y(0) {}
xyd(long double _x, long double _y) : x(_x), y(_y) {}
};
using vec = vector<lint>;
using vecd = vector<ld>;
using vecs = vector<string>;
using vecp = vector<xy>;
template <class T> using vect = vector<T>;
class vec2 : public vector<vector<lint>> {
public:
vec2() {}
vec2(lint n) : vector(n) {}
vec2(lint h, lint w) : vector(h, vector<lint>(w)) {}
vec2(lint h, lint w, lint v) : vector(h, vector<lint>(w, v)) {}
};
template <class T> using priq = priority_queue<T>;
template <class T> using rpriq = priority_queue<T, vector<T>, greater<T>>;
const ulint mod = 1000000007;
// const ulint mod = 998244353;
const double pi = 3.141592653589793238462;
const lint intmax = 9223372036854775807;
const lint inf = 1100100100100100100LL;
const ld eps = 0.0000001;
const lint alpn = 'z' - 'a' + 1;
template <class T> constexpr auto msum(T arg0) { return arg0; }
template <class T, class... Types> constexpr auto msum(T arg0, Types... args) {
static_assert(sizeof...(args) > 0, "arg err");
return arg0 + msum(args...);
}
template <class It> constexpr typename It::value_type mmax(It begin, It end) {
return *max_element(begin, end);
}
template <class It> constexpr typename It::value_type mmin(It begin, It end) {
return *min_element(begin, end);
}
template <class T> constexpr auto mmax(T arg) { return arg; }
template <class T, class... Types> constexpr auto mmax(T arg0, Types... args) {
using promote_t = decltype(msum(arg0, args...));
return max(static_cast<promote_t>(arg0),
static_cast<promote_t>(mmax(args...)));
}
template <class T> constexpr auto mmin(T arg) { return arg; }
template <class T, class... Types> constexpr auto mmin(T arg0, Types... args) {
using promote_t = decltype(msum(arg0, args...));
return min(static_cast<promote_t>(arg0),
static_cast<promote_t>(mmin(args...)));
}
template <class T> struct Mplus {
T operator()(const T &a, const T &b) { return a + b; }
const static T id = T(0);
};
template <class It, class T = typename It::value_type, class Monoid = Mplus<T>>
T acc(It begin, It end, Monoid f = Mplus<T>()) {
return accumulate(begin, end, Monoid::id, f);
}
constexpr auto clamp(lint val, lint left, lint right) {
return mmax(mmin(val, right), left);
}
constexpr lint div2(lint p, lint q) { return (p + q - 1) / q; }
#if (__cplusplus < 201703L)
lint gcd(lint a, lint b) {
while (1) {
if (a < b)
swap(a, b);
if (!b)
break;
a %= b;
}
return a;
}
lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
#endif
lint powInt(lint a, lint b) {
if (b == 0) {
return 1;
}
if (b == 1) {
return a;
}
lint tmp = powInt(a, b / 2);
return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp);
}
template <class T> T sgn(T val) {
if (val == T(0))
return T(0);
if (val < 0)
return T(-1);
if (val > 0)
return T(1);
}
template <class T> constexpr auto modK_belowN(T k, T MOD, T n) {
return (n + MOD - k - 1) / MOD;
}
template <class It, class T> bool exist(It begin, It end, const T &val) {
return find(begin, end, val) != end;
}
template <class It, class Pr> bool exist_if(It begin, It end, Pr pred) {
return find_if(begin, end, pred) != end;
}
template <class T> bool between(T val, T l, T r) {
return (val >= l) && (val <= r);
}
template <class It> auto carr(It begin, It end) {
vec c;
c.push_back(1);
auto before = *begin;
for (auto it = begin + 1; it != end; it++) {
if (before != *it) {
c.push_back(0);
before = *it;
}
c.back()++;
}
return c;
}
template <class T> struct nval {
lint n;
T val;
nval() : n(0){};
nval(lint _n, T _val) : n(_n), val(_val){};
};
template <class It> auto carr2(It begin, It end) {
using T = nval<remove_reference_t<decltype(*begin)>>;
vect<T> c;
c.push_back(T(1, *begin));
auto before = *begin;
for (auto it = begin + 1; it != end; it++) {
if (before != *it) {
c.push_back(T(0, *it));
before = *it;
}
c.back().n++;
}
return c;
}
template <class It, class... T> void sort2(It begin, It end, T... p) {
using val_t = remove_reference_t<decltype(*begin)>;
sort(begin, end, [p...](val_t a, val_t b) {
bool neq[] = {(a.*p != b.*p)...};
bool sg[] = {(a.*p < b.*p)...};
rep(i, sizeof...(p)) {
if (neq[i]) {
return sg[i];
}
}
return false;
});
}
template <size_t _K, size_t _N, class... Types, size_t... indices>
auto constexpr __ModKtuple_Impl(index_sequence<indices...>,
tuple<Types...> args) {
return make_tuple(get<indices * _N + _K>(args)...);
}
template <size_t K, size_t N, class... Types>
auto constexpr ModKtuple(Types... args) {
return __ModKtuple_Impl<K, N>(
make_index_sequence<modK_belowN(K, N, sizeof...(args))>{},
forward_as_tuple(args...));
}
template <class It, class... T, class... Tsg, size_t... indices>
void __sort3_Impl(It begin, It end, tuple<T...> p, tuple<Tsg...> sgf,
index_sequence<indices...>) {
using val_t = remove_reference_t<decltype(*begin)>;
sort(begin, end, [p, sgf](val_t a, val_t b) {
bool neq[] = {(a.*(get<indices>(p)) != b.*(get<indices>(p)))...};
bool sg[] = {((a.*(get<indices>(p)) < b.*(get<indices>(p))) !=
(get<indices>(sgf)))...};
rep(i, sizeof...(indices)) {
if (neq[i]) {
return sg[i];
}
}
return false;
});
}
template <class It, class... T> void sort3(It begin, It end, T... p) {
using val_t = remove_reference_t<decltype(*begin)>;
auto p_forward = ModKtuple<0, 2>(p...);
auto sgf_forward = ModKtuple<1, 2>(p...);
constexpr auto p_sz = tuple_size<decltype(p_forward)>::value;
constexpr auto sgf_sz = tuple_size<decltype(sgf_forward)>::value;
static_assert(p_sz == sgf_sz, "arg err");
__sort3_Impl(begin, end, p_forward, sgf_forward, make_index_sequence<p_sz>{});
}
template <class It, class It2> auto spacel(It i, It2 end) {
if (i + 1 == end) {
return '\n';
} else {
return ' ';
}
}
bool match(string s, string r) { return regex_match(s, regex(r)); }
template <class It> bool next_comb(lint n, It begin, It end) {
auto rend = make_reverse_iterator(begin);
auto rbegin = make_reverse_iterator(end);
auto rit = rbegin;
for (; rit != rend; rit++) {
if ((rit == rbegin && (*rit) + 1 != n) ||
(rit != rbegin && (*rit) + 1 != *(rit - 1))) {
goto found;
}
}
return false;
found:;
(*rit)++;
for (auto it = rit.base(); it != end; it++) {
(*it) = (*(it - 1)) + 1;
}
return true;
}
ostream &setp(ostream &ost) {
cout << setprecision(60) << fixed;
return ost;
}
#ifdef _LOCAL
auto &dbg = cout;
#else
struct dummy_cout {
template <class T> dummy_cout &operator<<(T &&op) { return *this; }
using endl_t = basic_ostream<char, char_traits<char>>;
dummy_cout &operator<<(endl_t &(*)(endl_t &)) { return *this; }
};
dummy_cout dbg;
#endif
}; // namespace
int main() {
lint n;
cin >> n;
vec a(n);
rep(i, n) cin >> a[i];
sort(all(a));
auto c = carr(all(a));
if (a.front() == 0 && a.back() == 0) {
cout << "Yes" << endl;
ret;
}
if (n % 3 != 0) {
cout << "No" << endl;
ret;
}
if (a[n / 3 * 0] == a[n / 3 * 1 - 1] && a[n / 3 * 1] == a[n / 3 * 2 - 1] &&
a[n / 3 * 2] == a[n / 3 * 3 - 1] && a[0] ^ a[n / 3] == a[(n / 3) * 2])
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define rep(i, n) for (lint i = 0; i < n; i++)
#define repr(i, n) for (lint i = n - 1; i >= 0; i--)
#define repi(i, ini, n) for (lint i = ini; i < n; i++)
#define repir(i, ini, n) for (lint i = n - 1; i >= ini; i--)
#define repb(i, start, end) for (lint i = start; i <= end; i++)
#define repbr(i, start, end) for (lint i = end; i >= start; i--)
#define bit(n) (1LL << n)
#define brep(i, n) rep(i, bit(n))
#define brepi(i, ini, n) repi(i, ini, bit(n))
#define len(a) (static_cast<lint>(a.size()))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rg(v, n) v.begin(), v.begin() + n
#define rrg(v, n) v.rbegin(), v.rbegin() + n
#define ret return 0;
namespace {
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
struct xy {
lint x, y;
xy() : x(0), y(0) {}
xy(lint _x, lint _y) : x(_x), y(_y) {}
xy operator+(const xy &p) const { return xy(x + p.x, y + p.y); }
bool operator<(xy p) const {
if (y == p.y)
return x < p.x;
return y < p.y;
}
};
struct xyd {
ld x, y;
xyd() : x(0), y(0) {}
xyd(long double _x, long double _y) : x(_x), y(_y) {}
};
using vec = vector<lint>;
using vecd = vector<ld>;
using vecs = vector<string>;
using vecp = vector<xy>;
template <class T> using vect = vector<T>;
class vec2 : public vector<vector<lint>> {
public:
vec2() {}
vec2(lint n) : vector(n) {}
vec2(lint h, lint w) : vector(h, vector<lint>(w)) {}
vec2(lint h, lint w, lint v) : vector(h, vector<lint>(w, v)) {}
};
template <class T> using priq = priority_queue<T>;
template <class T> using rpriq = priority_queue<T, vector<T>, greater<T>>;
const ulint mod = 1000000007;
// const ulint mod = 998244353;
const double pi = 3.141592653589793238462;
const lint intmax = 9223372036854775807;
const lint inf = 1100100100100100100LL;
const ld eps = 0.0000001;
const lint alpn = 'z' - 'a' + 1;
template <class T> constexpr auto msum(T arg0) { return arg0; }
template <class T, class... Types> constexpr auto msum(T arg0, Types... args) {
static_assert(sizeof...(args) > 0, "arg err");
return arg0 + msum(args...);
}
template <class It> constexpr typename It::value_type mmax(It begin, It end) {
return *max_element(begin, end);
}
template <class It> constexpr typename It::value_type mmin(It begin, It end) {
return *min_element(begin, end);
}
template <class T> constexpr auto mmax(T arg) { return arg; }
template <class T, class... Types> constexpr auto mmax(T arg0, Types... args) {
using promote_t = decltype(msum(arg0, args...));
return max(static_cast<promote_t>(arg0),
static_cast<promote_t>(mmax(args...)));
}
template <class T> constexpr auto mmin(T arg) { return arg; }
template <class T, class... Types> constexpr auto mmin(T arg0, Types... args) {
using promote_t = decltype(msum(arg0, args...));
return min(static_cast<promote_t>(arg0),
static_cast<promote_t>(mmin(args...)));
}
template <class T> struct Mplus {
T operator()(const T &a, const T &b) { return a + b; }
const static T id = T(0);
};
template <class It, class T = typename It::value_type, class Monoid = Mplus<T>>
T acc(It begin, It end, Monoid f = Mplus<T>()) {
return accumulate(begin, end, Monoid::id, f);
}
constexpr auto clamp(lint val, lint left, lint right) {
return mmax(mmin(val, right), left);
}
constexpr lint div2(lint p, lint q) { return (p + q - 1) / q; }
#if (__cplusplus < 201703L)
lint gcd(lint a, lint b) {
while (1) {
if (a < b)
swap(a, b);
if (!b)
break;
a %= b;
}
return a;
}
lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
#endif
lint powInt(lint a, lint b) {
if (b == 0) {
return 1;
}
if (b == 1) {
return a;
}
lint tmp = powInt(a, b / 2);
return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp);
}
template <class T> T sgn(T val) {
if (val == T(0))
return T(0);
if (val < 0)
return T(-1);
if (val > 0)
return T(1);
}
template <class T> constexpr auto modK_belowN(T k, T MOD, T n) {
return (n + MOD - k - 1) / MOD;
}
template <class It, class T> bool exist(It begin, It end, const T &val) {
return find(begin, end, val) != end;
}
template <class It, class Pr> bool exist_if(It begin, It end, Pr pred) {
return find_if(begin, end, pred) != end;
}
template <class T> bool between(T val, T l, T r) {
return (val >= l) && (val <= r);
}
template <class It> auto carr(It begin, It end) {
vec c;
c.push_back(1);
auto before = *begin;
for (auto it = begin + 1; it != end; it++) {
if (before != *it) {
c.push_back(0);
before = *it;
}
c.back()++;
}
return c;
}
template <class T> struct nval {
lint n;
T val;
nval() : n(0){};
nval(lint _n, T _val) : n(_n), val(_val){};
};
template <class It> auto carr2(It begin, It end) {
using T = nval<remove_reference_t<decltype(*begin)>>;
vect<T> c;
c.push_back(T(1, *begin));
auto before = *begin;
for (auto it = begin + 1; it != end; it++) {
if (before != *it) {
c.push_back(T(0, *it));
before = *it;
}
c.back().n++;
}
return c;
}
template <class It, class... T> void sort2(It begin, It end, T... p) {
using val_t = remove_reference_t<decltype(*begin)>;
sort(begin, end, [p...](val_t a, val_t b) {
bool neq[] = {(a.*p != b.*p)...};
bool sg[] = {(a.*p < b.*p)...};
rep(i, sizeof...(p)) {
if (neq[i]) {
return sg[i];
}
}
return false;
});
}
template <size_t _K, size_t _N, class... Types, size_t... indices>
auto constexpr __ModKtuple_Impl(index_sequence<indices...>,
tuple<Types...> args) {
return make_tuple(get<indices * _N + _K>(args)...);
}
template <size_t K, size_t N, class... Types>
auto constexpr ModKtuple(Types... args) {
return __ModKtuple_Impl<K, N>(
make_index_sequence<modK_belowN(K, N, sizeof...(args))>{},
forward_as_tuple(args...));
}
template <class It, class... T, class... Tsg, size_t... indices>
void __sort3_Impl(It begin, It end, tuple<T...> p, tuple<Tsg...> sgf,
index_sequence<indices...>) {
using val_t = remove_reference_t<decltype(*begin)>;
sort(begin, end, [p, sgf](val_t a, val_t b) {
bool neq[] = {(a.*(get<indices>(p)) != b.*(get<indices>(p)))...};
bool sg[] = {((a.*(get<indices>(p)) < b.*(get<indices>(p))) !=
(get<indices>(sgf)))...};
rep(i, sizeof...(indices)) {
if (neq[i]) {
return sg[i];
}
}
return false;
});
}
template <class It, class... T> void sort3(It begin, It end, T... p) {
using val_t = remove_reference_t<decltype(*begin)>;
auto p_forward = ModKtuple<0, 2>(p...);
auto sgf_forward = ModKtuple<1, 2>(p...);
constexpr auto p_sz = tuple_size<decltype(p_forward)>::value;
constexpr auto sgf_sz = tuple_size<decltype(sgf_forward)>::value;
static_assert(p_sz == sgf_sz, "arg err");
__sort3_Impl(begin, end, p_forward, sgf_forward, make_index_sequence<p_sz>{});
}
template <class It, class It2> auto spacel(It i, It2 end) {
if (i + 1 == end) {
return '\n';
} else {
return ' ';
}
}
bool match(string s, string r) { return regex_match(s, regex(r)); }
template <class It> bool next_comb(lint n, It begin, It end) {
auto rend = make_reverse_iterator(begin);
auto rbegin = make_reverse_iterator(end);
auto rit = rbegin;
for (; rit != rend; rit++) {
if ((rit == rbegin && (*rit) + 1 != n) ||
(rit != rbegin && (*rit) + 1 != *(rit - 1))) {
goto found;
}
}
return false;
found:;
(*rit)++;
for (auto it = rit.base(); it != end; it++) {
(*it) = (*(it - 1)) + 1;
}
return true;
}
ostream &setp(ostream &ost) {
cout << setprecision(60) << fixed;
return ost;
}
#ifdef _LOCAL
auto &dbg = cout;
#else
struct dummy_cout {
template <class T> dummy_cout &operator<<(T &&op) { return *this; }
using endl_t = basic_ostream<char, char_traits<char>>;
dummy_cout &operator<<(endl_t &(*)(endl_t &)) { return *this; }
};
dummy_cout dbg;
#endif
}; // namespace
int main() {
lint n;
cin >> n;
vec a(n);
rep(i, n) cin >> a[i];
sort(all(a));
auto c = carr(all(a));
if (a.front() == 0 && a.back() == 0) {
cout << "Yes" << endl;
ret;
}
if (n % 3 != 0) {
cout << "No" << endl;
ret;
}
if (a[n / 3 * 0] == a[n / 3 * 1 - 1] && a[n / 3 * 1] == a[n / 3 * 2 - 1] &&
a[n / 3 * 2] == a[n / 3 * 3 - 1] && (a[0] ^ a[n / 3]) == a[(n / 3) * 2])
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
| [
"control_flow.branch.if.condition.change"
] | 781,571 | 781,572 | u275797573 | cpp |
p02975 | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m) {
long long ans = 1;
while (n) {
if (n & 1) {
ans = (ans * a) % m;
}
a = (a * a) % m;
n >>= 1;
}
return ans;
}
long long combi(long long n, long long a) {
long long ans = 1, ans1 = 1;
for (long long i = n - a + 1; i <= n; i++) {
ans *= i % MOD;
ans %= MOD;
}
for (long long i = 2; i <= a; i++)
ans1 = (ans1 * i) % MOD;
ans1 = modpow(ans1, MOD - 2, MOD);
return ((ans % MOD) * ans1) % MOD;
}
template <typename T>
bool next_combination(const T first, const T last, int k) {
const T subset = first + k;
// empty container | k = 0 | k == n
if (first == last || first == subset || last == subset) {
return false;
}
T src = subset;
while (first != src) {
src--;
if (*src < *(last - 1)) {
T dest = subset;
while (*src >= *dest) {
dest++;
}
iter_swap(src, dest);
rotate(src + 1, dest + 1, last);
rotate(subset, subset + (last - dest) - 1, last);
return true;
}
}
// restore
rotate(first, subset, last);
return false;
}
void dfs(string s, char mx, ll N) {
if (s.length() == (size_t)N) {
cout << s.c_str() << endl;
} else {
for (char c = 'a'; c <= mx; c++) {
dfs(s + c, ((c == mx) ? (char)(mx) : mx), N);
}
}
}
int bfs(int a, int b, int h, int w, char tmp[][101]) {
int ans[101][101] = {0};
char c[101][101] = {0};
queue<pair<int, int>> s;
for (int i = 0; i <= h; i++) {
for (int j = 0; j <= w; j++) {
c[i][j] = tmp[i][j];
}
}
s.push(make_pair(a, b));
while (s.size() > 0) {
pair<int, int> tmp = s.front();
s.pop();
c[tmp.first][tmp.second] = '#';
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
if (tmp.first + i < 1 || tmp.first + i > h) {
continue;
}
if (tmp.second + j < 1 || tmp.second + j > w) {
continue;
}
if (i != 0 && j != 0) {
continue;
}
if (i == 0 && j == 0) {
continue;
}
if (c[tmp.first + i][tmp.second + j] == '#') {
continue;
}
c[tmp.first + i][tmp.second + j] = '#';
if (ans[tmp.first + i][tmp.second + j] == 0) {
ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
} else {
ans[tmp.first + i][tmp.second + j] =
min(ans[tmp.first + i][tmp.second + j],
ans[tmp.first][tmp.second] + 1);
}
s.push(make_pair(tmp.first + i, tmp.second + j));
}
}
}
int asd = 0;
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
asd = max(a, ans[i][j]);
}
}
return asd;
}
ll modfactorial(ll a) {
if (a == 1)
return 1;
return (a % MOD) * (modfactorial(a - 1) % MOD);
}
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
ll n;
cin >> n;
vector<ll> a(32);
for (int i = 0; i < n; i++) {
ll tmp;
cin >> tmp;
string s =
bitset<32>(tmp)
.to_string<char, std::char_traits<char>, std::allocator<char>>();
for (int i = 0; i < 32; i++) {
if (s[i] == '1') {
a[i]++;
}
}
}
bool f = true;
for (int i = 0; i < 32; i++) {
if (a[i] % 2 != 2 && a[i] != 0) {
f = false;
}
}
cout << (f ? "Yes" : "No") << endl;
return 0;
}
// cout << std::fixed << std::setprecision(15)
| #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m) {
long long ans = 1;
while (n) {
if (n & 1) {
ans = (ans * a) % m;
}
a = (a * a) % m;
n >>= 1;
}
return ans;
}
long long combi(long long n, long long a) {
long long ans = 1, ans1 = 1;
for (long long i = n - a + 1; i <= n; i++) {
ans *= i % MOD;
ans %= MOD;
}
for (long long i = 2; i <= a; i++)
ans1 = (ans1 * i) % MOD;
ans1 = modpow(ans1, MOD - 2, MOD);
return ((ans % MOD) * ans1) % MOD;
}
template <typename T>
bool next_combination(const T first, const T last, int k) {
const T subset = first + k;
// empty container | k = 0 | k == n
if (first == last || first == subset || last == subset) {
return false;
}
T src = subset;
while (first != src) {
src--;
if (*src < *(last - 1)) {
T dest = subset;
while (*src >= *dest) {
dest++;
}
iter_swap(src, dest);
rotate(src + 1, dest + 1, last);
rotate(subset, subset + (last - dest) - 1, last);
return true;
}
}
// restore
rotate(first, subset, last);
return false;
}
void dfs(string s, char mx, ll N) {
if (s.length() == (size_t)N) {
cout << s.c_str() << endl;
} else {
for (char c = 'a'; c <= mx; c++) {
dfs(s + c, ((c == mx) ? (char)(mx) : mx), N);
}
}
}
int bfs(int a, int b, int h, int w, char tmp[][101]) {
int ans[101][101] = {0};
char c[101][101] = {0};
queue<pair<int, int>> s;
for (int i = 0; i <= h; i++) {
for (int j = 0; j <= w; j++) {
c[i][j] = tmp[i][j];
}
}
s.push(make_pair(a, b));
while (s.size() > 0) {
pair<int, int> tmp = s.front();
s.pop();
c[tmp.first][tmp.second] = '#';
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
if (tmp.first + i < 1 || tmp.first + i > h) {
continue;
}
if (tmp.second + j < 1 || tmp.second + j > w) {
continue;
}
if (i != 0 && j != 0) {
continue;
}
if (i == 0 && j == 0) {
continue;
}
if (c[tmp.first + i][tmp.second + j] == '#') {
continue;
}
c[tmp.first + i][tmp.second + j] = '#';
if (ans[tmp.first + i][tmp.second + j] == 0) {
ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
} else {
ans[tmp.first + i][tmp.second + j] =
min(ans[tmp.first + i][tmp.second + j],
ans[tmp.first][tmp.second] + 1);
}
s.push(make_pair(tmp.first + i, tmp.second + j));
}
}
}
int asd = 0;
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
asd = max(a, ans[i][j]);
}
}
return asd;
}
ll modfactorial(ll a) {
if (a == 1)
return 1;
return (a % MOD) * (modfactorial(a - 1) % MOD);
}
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
ll n;
cin >> n;
vector<ll> a(32);
for (int i = 0; i < n; i++) {
ll tmp;
cin >> tmp;
string s =
bitset<32>(tmp)
.to_string<char, std::char_traits<char>, std::allocator<char>>();
for (int i = 0; i < 32; i++) {
if (s[i] == '1') {
a[i]++;
}
}
}
bool f = true;
for (int i = 0; i < 32; i++) {
if (a[i] % 2 != 0 && a[i] != 0) {
f = false;
}
}
cout << (f ? "Yes" : "No") << endl;
return 0;
}
// cout << std::fixed << std::setprecision(15)
| [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 781,588 | 781,589 | u303297838 | cpp |
p02975 | #include <algorithm>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second
void print(bool c) { (c) ? (cout << "Yes" << endl) : (cout << "No" << endl); }
void Print(bool c) { (c) ? (cout << "YES" << endl) : (cout << "NO" << endl); }
//最小公倍数
template <typename T> T gcd(T a, T b) {
while (1) {
if (a < b)
swap(a, b);
if (b == 0)
break;
a %= b;
}
return a;
}
//最大公約数
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b) {
if (a.second != b.second)
return a.second < b.second;
return a.first < b.first;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int eve(int x) {
if (x % 400 == 0)
return 1;
if (x % 100 == 0)
return 0;
if (x % 4 == 0)
return 1;
return 0;
}
int main(void) {
ll n;
cin >> n;
vll a(n);
ll zero = 0;
rep(i, 0, n) {
cin >> a[i];
if (!a[i])
zero++;
}
if (zero == n)
return print(1), 0;
if (n % 3 != 0)
return print(0), 0;
sort_v(a);
if (a[0] == a[n / 3 - 1] && a[n / 3] == a[n - 1] && a[0] == 0)
return print(1), 0;
if (a[0] == a[n / 3 - 1] && a[n / 3] == a[2 * n / 3 - 1] &&
a[2 * n / 3] == a[n - 1] && a[0] ^ a[n / 3] ^ a[2 * n / 3] == 0)
return print(1), 0;
print(0);
} | #include <algorithm>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second
void print(bool c) { (c) ? (cout << "Yes" << endl) : (cout << "No" << endl); }
void Print(bool c) { (c) ? (cout << "YES" << endl) : (cout << "NO" << endl); }
//最小公倍数
template <typename T> T gcd(T a, T b) {
while (1) {
if (a < b)
swap(a, b);
if (b == 0)
break;
a %= b;
}
return a;
}
//最大公約数
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b) {
if (a.second != b.second)
return a.second < b.second;
return a.first < b.first;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int eve(int x) {
if (x % 400 == 0)
return 1;
if (x % 100 == 0)
return 0;
if (x % 4 == 0)
return 1;
return 0;
}
int main(void) {
ll n;
cin >> n;
vll a(n);
ll zero = 0;
rep(i, 0, n) {
cin >> a[i];
if (!a[i])
zero++;
}
if (zero == n)
return print(1), 0;
if (n % 3 != 0)
return print(0), 0;
sort_v(a);
if (a[0] == a[n / 3 - 1] && a[n / 3] == a[n - 1] && a[0] == 0)
return print(1), 0;
if (a[0] == a[n / 3 - 1] && a[n / 3] == a[2 * n / 3 - 1] &&
a[2 * n / 3] == a[n - 1] && ((a[0] ^ a[n / 3]) ^ a[2 * n / 3]) == 0)
return print(1), 0;
print(0);
} | [
"control_flow.branch.if.condition.change"
] | 781,593 | 781,594 | u705296057 | cpp |
p02975 | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF = 1e+18 + 1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
const ll MOD = 1000000007LL;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vl dy = {1, -1, 0, 1, -1, 1, 0, -1};
int main() {
ll n;
cin >> n;
vl a(n);
rep(i, n) cin >> a[i];
set<ll> S;
vl vec;
map<ll, ll> M;
rep(i, n) {
M[a[i]]++;
if (!S.count(a[i])) {
vec.push_back(a[i]);
S.insert(a[i]);
}
}
if (vec.size() == 1 && vec[0] == 0) {
cout << "Yes" << endl;
return 0;
}
if (S.size() == 2 && n % 3 == 0 && M[0] == n / 3 * 2) {
cout << "Yes" << endl;
return 0;
}
if ((vec[0] ^ vec[1]) == vec[2] && M[vec[0]] == M[vec[1]] &&
M[vec[1]] == M[vec[2]]) {
cout << "Yes" << endl;
return 0;
}
cout << "No" << endl;
} | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF = 1e+18 + 1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
const ll MOD = 1000000007LL;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vl dy = {1, -1, 0, 1, -1, 1, 0, -1};
int main() {
ll n;
cin >> n;
vl a(n);
rep(i, n) cin >> a[i];
set<ll> S;
vl vec;
map<ll, ll> M;
rep(i, n) {
M[a[i]]++;
if (!S.count(a[i])) {
vec.push_back(a[i]);
S.insert(a[i]);
}
}
if (vec.size() == 1 && vec[0] == 0) {
cout << "Yes" << endl;
return 0;
}
if (S.size() == 2 && n % 3 == 0 && M[0] == n / 3) {
cout << "Yes" << endl;
return 0;
}
if ((vec[0] ^ vec[1]) == vec[2] && M[vec[0]] == M[vec[1]] &&
M[vec[1]] == M[vec[2]]) {
cout << "Yes" << endl;
return 0;
}
cout << "No" << endl;
} | [
"expression.operation.binary.remove"
] | 781,597 | 781,598 | u614128939 | cpp |
p02975 | #include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i, m, n) for (lli i = m; i < n; i++)
#define rrep(i, m, n) for (lli i = m - 1; i >= n; i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(), N.end()), N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(), n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K, L, N, S) vector<L> K(N, S)
#define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S))
#define TV(K, L, N, M, R, S) \
vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S)))
#define pint pair<lli, lli>
#define paf(L, R) pair<L, R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a) a.begin(), a.end()
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
lli A, B, C, D, E, F, N, M, K, L, X, Y, Z, H, W, sum = 0, num = 0, flag = 0;
string S, T;
cin >> N;
Vec(P, lli, N, 0);
rep(i, 0, N) cin >> P[i];
map<int, int> mp;
rep(i, 0, N) mp[P[i]]++;
if (mp.size() > 3)
flag = 1;
else if (mp.size() == 3) {
for (auto v : mp)
if (v.second != N / 3)
flag = 1;
for (auto v : mp)
sum ^= v.second;
if (sum)
flag = 1;
} else if (mp.size() == 2) {
if (mp[0] != N / 3 || N % 3 != 0 || mp.count(0) == 0)
flag = 1;
} else if (mp.size() == 1)
if (mp.count(0) == 0)
flag = 1;
if (flag)
Out("No");
else
Out("Yes");
} | #include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i, m, n) for (lli i = m; i < n; i++)
#define rrep(i, m, n) for (lli i = m - 1; i >= n; i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(), N.end()), N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(), n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K, L, N, S) vector<L> K(N, S)
#define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S))
#define TV(K, L, N, M, R, S) \
vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S)))
#define pint pair<lli, lli>
#define paf(L, R) pair<L, R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a) a.begin(), a.end()
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
lli A, B, C, D, E, F, N, M, K, L, X, Y, Z, H, W, sum = 0, num = 0, flag = 0;
string S, T;
cin >> N;
Vec(P, lli, N, 0);
rep(i, 0, N) cin >> P[i];
map<int, int> mp;
rep(i, 0, N) mp[P[i]]++;
if (mp.size() > 3)
flag = 1;
else if (mp.size() == 3) {
for (auto v : mp)
if (v.second != N / 3)
flag = 1;
for (auto v : mp)
sum ^= v.first;
if (sum)
flag = 1;
} else if (mp.size() == 2) {
if (mp[0] != N / 3 || N % 3 != 0 || mp.count(0) == 0)
flag = 1;
} else if (mp.size() == 1)
if (mp.count(0) == 0)
flag = 1;
if (flag)
Out("No");
else
Out("Yes");
} | [
"assignment.value.change"
] | 781,601 | 781,602 | u618604643 | cpp |
p02975 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
signed main(void) {
int n, x[3], cnt_0;
cin >> n;
vector<int> a(n);
map<ll, ll> mp;
bool ok;
cnt_0 = 0;
rep(i, n) {
cin >> a[i];
if (a[i] == 0)
cnt_0++;
mp[a[i]]++;
}
if (cnt_0 == n)
ok = true;
else if (n % 3 == 0) {
if (cnt_0 == n / 3 && mp.size() == 1)
ok = true;
else {
if (mp.size() == 3) {
ok = true;
int i = 0;
for (auto p : mp) {
x[i++] = p.first;
if (p.second != n / 3)
ok = false;
}
if (ok && (!((x[0] ^ x[1] ^ x[2]) == 0)))
ok = false;
} else
ok = false;
}
} else
ok = false;
if (ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
signed main(void) {
int n, x[3], cnt_0;
cin >> n;
vector<int> a(n);
map<ll, ll> mp;
bool ok;
cnt_0 = 0;
rep(i, n) {
cin >> a[i];
if (a[i] == 0)
cnt_0++;
mp[a[i]]++;
}
if (cnt_0 == n)
ok = true;
else if (n % 3 == 0) {
if (cnt_0 == n / 3 && mp.size() == 2)
ok = true;
else {
if (mp.size() == 3) {
ok = true;
int i = 0;
for (auto p : mp) {
x[i++] = p.first;
if (p.second != n / 3)
ok = false;
}
if (ok && (!((x[0] ^ x[1] ^ x[2]) == 0)))
ok = false;
} else
ok = false;
}
} else
ok = false;
if (ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
| [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 781,603 | 781,604 | u890331732 | cpp |
p02975 | // a_2 = a_1 xor a_3 = (a_0 xor a_2) xor a_3
// このことから、 a_0 xor a_3 = 0 つまり a_0 = a_3であることがわかる。
// N == 3*k (k = 1,2,3,...)のとき、
// {a_i}が3つの数から成り、b_0, b_1, b_2として、b_0 xor b_1 =
// b_2が成り立つか判定 N % 3 != 0
// なら、全ての数が等しくなるか(0になる)どうか判定
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
if (N % 3) {
int a;
cin >> a;
if (a != 0) {
cout << "No" << endl;
return 0;
}
for (int i = 1; i < N; ++i) {
int tmp;
cin >> tmp;
if (a != tmp) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
}
map<int, int> Map;
for (int i = 0; i < N; ++i) {
int a;
cin >> a;
++Map[a];
}
vector<int> B, Num;
for (auto &p : Map) {
B.push_back(p.first);
Num.push_back(p.second);
}
/*
for(int i = 0; i < Num.size(); ++i) {
cout << "B: " << B[i] << " Num: " << Num[i] << endl;
}
*/
if (Num.size() > 3) {
cout << "No" << endl;
return 0;
}
if (Num.size() == 3) {
if (Num[0] != Num[1] || Num[1] != Num[2] || Num[2] != Num[0]) {
cout << "No" << endl;
return 0;
}
if (B[0] ^ B[1] == B[2])
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
if (Num.size() == 2) {
if (Num[0] > Num[1]) {
swap(Num[0], Num[1]);
swap(B[0], B[1]);
}
if (B[0] != 0) {
cout << "No" << endl;
return 0;
}
if (Num[0] * 2 == Num[1]) {
cout << "Yes" << endl;
} else
cout << "No" << endl;
return 0;
}
if (Num.size() == 1) {
if (B[0] == 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
} | // a_2 = a_1 xor a_3 = (a_0 xor a_2) xor a_3
// このことから、 a_0 xor a_3 = 0 つまり a_0 = a_3であることがわかる。
// N == 3*k (k = 1,2,3,...)のとき、
// {a_i}が3つの数から成り、b_0, b_1, b_2として、b_0 xor b_1 =
// b_2が成り立つか判定 N % 3 != 0
// なら、全ての数が等しくなるか(0になる)どうか判定
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
if (N % 3) {
int a;
cin >> a;
if (a != 0) {
cout << "No" << endl;
return 0;
}
for (int i = 1; i < N; ++i) {
int tmp;
cin >> tmp;
if (a != tmp) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
}
map<int, int> Map;
for (int i = 0; i < N; ++i) {
int a;
cin >> a;
++Map[a];
}
vector<int> B, Num;
for (auto &p : Map) {
B.push_back(p.first);
Num.push_back(p.second);
}
/*
for(int i = 0; i < Num.size(); ++i) {
cout << "B: " << B[i] << " Num: " << Num[i] << endl;
}
*/
if (Num.size() > 3) {
cout << "No" << endl;
return 0;
}
if (Num.size() == 3) {
if (Num[0] != Num[1] || Num[1] != Num[2] || Num[2] != Num[0]) {
cout << "No" << endl;
return 0;
}
// cout << B[0] << " xor " << B[1] << " = " << (B[0] ^ B[1]) << endl;
if ((B[0] ^ B[1]) == B[2])
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
if (Num.size() == 2) {
if (Num[0] > Num[1]) {
swap(Num[0], Num[1]);
swap(B[0], B[1]);
}
if (B[0] != 0) {
cout << "No" << endl;
return 0;
}
if (Num[0] * 2 == Num[1]) {
cout << "Yes" << endl;
} else
cout << "No" << endl;
return 0;
}
if (Num.size() == 1) {
if (B[0] == 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 781,605 | 781,606 | u816645498 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.