#include<bits/stdc++.h> #define mid(l, r) (l + ((r - l) >> 1)) #define sz(x) (int(x.size())) #define repeat(i, a, b) for (int i = (a); i <= (b); i++) #define until(i, a, b) for (int i = (a); i >= (b); i--) #define array_of(T, N) std::array<T, N> #define all(x) x.begin(), x.end() #define range(x, a, b) x + a, x + b + 1 using ll = longlong; using vi = std::vector<int>; using pii = std::pair<int, int>;
#include<bits/stdc++.h> #define mid(l, r) (l + ((r - l) >> 1)) #define sz(x) (int(x.size())) #define repeat(i, a, b) for (int i = (a); i <= (b); i++) #define until(i, a, b) for (int i = (a); i >= (b); i--) #define array_of(T, N) std::array<T, N> #define all(x) x.begin(), x.end() #define range(x, a, b) x + a, x + b + 1 using ll = longlong; using vi = std::vector<int>; using pii = std::pair<int, int>;
int a, b, c; constexprint N = 50;
voidRun(){ std::cin >> a >> b >> c; until(i, N, 0) { auto get = [&](int x) { return x >> i & 1; }; int f = get(a) + get(b) + get(c); if (f == 2) { std::cout << "NO\n"; return; } } std::cout << "YES\n"; }
#include<bits/stdc++.h> #define mid(l, r) (l + ((r - l) >> 1)) #define sz(x) (int(x.size())) #define repeat(i, a, b) for (int i = (a); i <= (b); i++) #define until(i, a, b) for (int i = (a); i >= (b); i--) #define array_of(T, N) std::array<T, N> #define all(x) x.begin(), x.end() #define range(x, a, b) x + a, x + b + 1 using ll = longlong; using vi = std::vector<int>; using pii = std::pair<int, int>;
ll ans = 0, ecnt = 0; std::vector<ll> rm; for (auto &[x, c] : cnt) { ans += x * (c - c % 2); ecnt += c - c % 2; c %= 2; if (c == 0) rm.push_back(x); } for (auto x : rm) cnt.erase(x); rm.clear();
// invalid if (ecnt == 0) { std::cout << "0\n"; return; } // no more single if (cnt.size() == 0) { std::cout << (ecnt == 2 ? 0 : ans) << "\n"; return; }
// select one ll tans = ans; for (auto it = cnt.begin(); it != cnt.end(); it++) { auto [x, c] = *it; assert(c == 1); if (x < ans) tans = std::max(tans, ans + x); }
// select 2 ll fans = ans; if (cnt.size() >= 2) { auto it = cnt.rbegin(), iit = std::next(it);
while (true) { if (iit == cnt.rend()) break; if (ans + iit->first > it->first) fans = std::max(ans + iit->first + it->first, fans); it++, iit++; } }
ll fe = ecnt; if (tans > ans) fe = ecnt + 1, ans = tans; if (fans > ans) fe = ecnt + 2, ans = fans;
#include<bits/stdc++.h> #define mid(l, r) (l + ((r - l) >> 1)) #define sz(x) (int(x.size())) #define repeat(i, a, b) for (int i = (a); i <= (b); i++) #define until(i, a, b) for (int i = (a); i >= (b); i--) #define array_of(T, N) std::array<T, N> #define all(x) x.begin(), x.end() #define range(x, a, b) x + a, x + b + 1 using ll = longlong; using vi = std::vector<int>; using pii = std::pair<int, int>;