text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
long long Ans = -1;
inline void ReNew(long long& Ans, long long x) {
if (Ans > x || Ans == -1) Ans = x;
}
int main() {
scanf("%I64d%I64d%I64d", &a, &b, &c);
if (a == b)
ReNew(Ans, a);
else if (b == c)
ReNew(Ans, b);
else if (a == c)
ReNew(Ans, c);
if (a < b) swap(a, b);
if (a < c) swap(a, c);
if (b < c) swap(b, c);
if (!((a - b) & 1)) ReNew(Ans, a);
if (!((b - c) & 1)) ReNew(Ans, b);
if (!((a - c) & 1)) ReNew(Ans, a);
cout << Ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long arr[4], a = 0;
for (int i = 0; i < 3; i++) {
cin >> arr[i];
a += arr[i];
}
a--;
for (int i = 0; i < 3; i++) {
for (int j = i + 1; j < 3; j++)
if (abs(arr[i] - arr[j]) % 2 == 0) a = min(a, max(arr[i], arr[j]));
}
cout << a;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
scanf("%lld%lld%lld", &a[0], &a[1], &a[2]);
sort(a, a + 3);
if ((a[1] - a[0]) % 2 == 0) {
printf("%lld\n", a[1]);
} else
printf("%lld\n", a[2]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long an[3];
vector<long long> ve[2];
int main() {
for (int i = (0); i <= (2); ++i) scanf("%lld", &an[i]);
for (int i = (0); i <= (2); ++i) ve[an[i] % 2].push_back(an[i]);
for (int i = (0); i <= (1); ++i) sort(ve[i].begin(), ve[i].end());
if (ve[0].size() == 2) {
printf("%lld\n", ve[0][1]);
} else if (ve[1].size() == 2) {
printf("%lld\n", ve[1][1]);
} else {
if (ve[1].size())
printf("%lld\n", ve[1][1]);
else
printf("%lld\n", ve[0][1]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[0] + a[1]) % 2 == 0)
cout << a[1] << endl;
else
cout << a[2] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[5];
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
cin >> a[1] >> a[2] >> a[3];
sort(a + 1, a + 4);
reverse(a + 1, a + 4);
if ((a[2] - a[3]) % 2 == 1) {
cout << a[1] << endl;
return 0;
}
cout << a[2] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, ans;
long long solve(long long a, long long b, long long c) { return max(b, c); }
int main() {
cin >> a >> b >> c;
ans = 1LL << 62;
if ((b & 1) == (c & 1)) ans = min(ans, solve(a, b, c));
if ((c & 1) == (a & 1)) ans = min(ans, solve(b, c, a));
if ((a & 1) == (b & 1)) ans = min(ans, solve(c, a, b));
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[5];
inline bool ev(long long x) { return !(abs(x) & 1); }
int main() {
cin >> a[0] >> a[1] >> a[2];
if (ev(a[0] - a[1]) && ev(a[0] - a[2]) && ev(a[1] - a[2])) {
sort(a, a + 3);
cout << a[1] << '\n';
} else {
if (ev(a[0] - a[2]))
swap(a[1], a[2]);
else if (ev(a[1] - a[2]))
swap(a[0], a[2]);
if (a[0] > a[1]) swap(a[0], a[1]);
long long d = (a[1] - a[0]) / 2;
d = min(d, a[2]);
long long ans = d;
a[0] += d;
a[1] -= d;
a[2] -= d;
if (a[0] == 0) {
cout << ans << '\n';
return 0;
} else {
ans += a[1];
cout << ans << '\n';
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
int main() {
long long a, b, c;
long long ans = INF;
cin >> a >> b >> c;
if ((a + b) % 2 == 0) ans = max(a, b);
if ((a + c) % 2 == 0) ans = min(max(a, c), ans);
if ((b + c) % 2 == 0) ans = min(max(b, c), ans);
if (ans == INF)
cout << "-1" << endl;
else
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long data[3];
int main() {
for (int i = 0; i < 3; ++i) scanf("%I64d", &data[i]);
sort(data, data + 3);
if ((data[1] - data[0]) & 1)
printf("%I64d\n", data[2]);
else
printf("%I64d\n", data[1]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[4];
int main() {
scanf("%lld %lld %lld", &a[1], &a[2], &a[3]);
sort(a + 1, a + 4);
if ((a[2] - a[1]) & 1)
printf("%lld", a[3]);
else
printf("%lld", a[2]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 100002;
long long n, m, k, p, q, ans, sum, tot, cnt, a[N], b[N], c[N], d[N];
signed main() {
cin >> a[1] >> a[2] >> a[3];
sort(a + 1, a + 3 + 1);
if ((a[2] - a[1]) % 2 == 0) {
cout << a[2];
return 0;
}
cout << a[3];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
template <typename T>
void printV(vector<T>& v) {
for (int i = 0; i < (int)(v.size()); i++) cout << v[i] << " ";
cout << endl;
}
template <typename T>
void printVs(vector<vector<T> >& v) {
for (int i = 0; i < (int)(v.size()); i++) printV(v[i]);
}
template <typename T>
void printVs(T** v, int H, int W) {
for (int i = 0; i < (int)(H); i++) {
for (int j = 0; j < (int)(W); j++) cout << v[i][j] << " ";
cout << endl;
}
}
void printV(vector<pair<int, int> >& v) {
for (int i = 0; i < (int)(v.size()); i++)
cout << "(" << v[i].first << "," << v[i].second << ") ";
}
void err() { cout << "wtf " << endl; }
int main() {
long long A[3];
for (int i = 0; i < (int)(3); i++) cin >> A[i];
long long sm = 0;
long long mx = 1LL << 32;
long long res = mx;
for (int i = 0; i < (int)(3); i++)
for (int j = (i + 1); j < (int)(3); j++)
if ((A[i] + A[j]) % 2 == 0) res = min(res, max(A[i], A[j]));
cout << (res == mx ? -1 : res) << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
for (long long int a, b, c; cin >> a >> b >> c;) {
multiset<long long int> s;
s.insert(a);
s.insert(b);
s.insert(c);
long long int z[2] = {0};
int i = 0;
for (multiset<long long int>::iterator it = s.begin(); i < 3; ++i, ++it)
z[i] = *it;
if ((z[1] + z[0]) % 2 == 0)
cout << z[1] << endl;
else
cout << z[2] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <class T1, class T2>
struct cmpf {
bool rev;
inline bool operator()(const pair<T1, T2>& a, const pair<T1, T2>& b) const {
return (a.first < b.first) ^ rev;
}
cmpf(bool b = false) { rev = b; }
};
template <class T1, class T2>
struct cmps {
bool rev;
inline bool operator()(const pair<T1, T2>& a, const pair<T1, T2>& b) const {
return (a.second < b.second) ^ rev;
}
cmps(bool b = false) { rev = b; }
};
long long binpow(long long x, long long p, const long long& mod) {
assert(mod > 0);
long long ret = 1;
for (; p > 0; p >>= 1, x = x * x % mod)
if (p & 1) ret = ret * x % mod;
return ret;
}
template <class T>
bool chmn(T& a, const T& b) {
return ((a > b) ? ((a = b) || true) : false);
}
template <class T>
bool chmx(T& a, const T& b) {
return ((a < b) ? ((a = b) || true) : false);
}
void setIO(const string& filename = "") {
cin.tie(0)->sync_with_stdio(0);
if (filename.size() > 0) {
freopen((filename + ".in").c_str(), "r", stdin);
freopen((filename + ".out").c_str(), "w", stdout);
}
}
int chr[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int chc[8] = {0, 1, 0, -1, -1, 1, -1, 1};
const long long MOD = 1e9 + 7;
const int INIT = 1001001001;
const int MN = 1001001;
const long long INF = 2e18;
long long N, M, K;
long long A[MN];
long long calc(long long a, long long b, long long c) {
long long ret = 0;
while (b > 0 || c > 0) {
(a, b, c, ret);
if (b > 0 && c > 0) {
long long x = min(b, c);
assert(x > 0);
a += x;
b -= x;
c -= x;
ret += x;
} else {
if (b < c) swap(b, c);
assert(b > 0);
assert(c == 0);
if (a == 0 && c == 0) return ret;
assert(a > 0);
if (b == 1) {
return ret + a;
}
long long x = b - (b & 1);
assert(x > 0);
b -= x;
ret += x;
}
}
return ret;
}
void solve(int testcase) {
cin >> A[0] >> A[1] >> A[2];
long long ans = INF;
for (int i = 0; i < 3; ++i) {
chmn(ans, calc(A[i], A[(i + 1) % 3], A[(i + 2) % 3]));
}
cout << ans << endl;
}
int main() {
setIO();
long long T = 1;
for (int t = 1; t <= T; t++) solve(t);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
int main() {
ios_base::sync_with_stdio(false);
long long a, b, c;
cin >> a >> b >> c;
long long mn = (1LL << 32);
if (a % 2 == b % 2) {
mn = min(mn, max(a, b));
}
if (a % 2 == c % 2) {
mn = min(mn, max(a, c));
}
if (b % 2 == c % 2) {
mn = min(mn, max(b, c));
}
cout << mn;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long getAns(long long b, long long c) {
if (b > c) swap(b, c);
if (b == 0)
return 0;
else if (b == 1)
return c;
else {
if (b % 2 == 0)
return b;
else
return c;
}
}
int main(int argc, char* argv[]) {
long long a, b, c;
while (scanf("%I64d%I64d%I64d", &a, &b, &c) >= 1) {
if (a > b) swap(a, b);
if (b > c) swap(b, c);
if (a > b) swap(a, b);
long long ans = 1e18;
ans = min(ans, getAns(b - a, c + a) + a);
ans = min(ans, getAns(c - a, b + a) + a);
ans = min(ans, getAns(a + b, c - b) + b);
printf("%I64d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int MOD = 1e9 + 7;
const int MAX = 1000001;
int main() {
ios::sync_with_stdio(false);
long long int v[3];
for (int i = 0, __ = 3; i < __; i++) cin >> v[i];
sort(v, v + 3);
if (v[0] % 2 == v[1] % 2)
cout << v[1];
else
cout << v[2];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3], p[2];
long long ans = 0, sum;
int main() {
for (int i = 0; i < 3; ++i) {
cin >> a[i];
ans += a[i];
p[a[i] % 2]++;
}
sum = ans;
for (int i = 0; i < 3; ++i) {
if ((p[0] == 0 || p[1] == 0) || p[a[i] % 2] == 1) {
long long h = a[i] + min(a[(i + 1) % 3], a[(i + 2) % 3]);
long long t = sum - h;
ans = min(ans, t);
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long a, b, c;
auto f = [](long long a, long long b) {
return ((a + b) & 1) ? (long long)1e18 : max(a, b);
};
cin >> a >> b >> c, cout << min({f(a, b), f(b, c), f(c, a)}) << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int X[] = {0, 0, 1, 0, 0, -1};
int Y[] = {0, 1, 0, 0, -1, 0};
int Z[] = {1, 0, 0, -1, 0, 0};
struct node {
int x, y;
node() {}
node(int x, int y) : x(x), y(y) {}
bool operator<(const node& p) const { return x < p.x; }
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long i, j, k, l, x, y, z, t, m, n = 0;
long long a[5];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[1] - a[0]) % 2 == 0) {
x = a[1];
} else
x = a[2];
cout << x;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, back, c;
long long min(long long a, long long back, long long c) {
return min(min(a, back), c);
}
long long max(long long a, long long back, long long c) {
return max(max(a, back), c);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(NULL);
cin >> a >> back >> c;
if (a % 2 == 0 && back % 2 == 0 && c % 2 == 0)
return cout << a + back + c - min(a, back, c) - max(a, back, c), 0;
if (a % 2 && back % 2 && c % 2)
return cout << a + back + c - min(a, back, c) - max(a, back, c), 0;
if (a % 2 && back % 2) return cout << max(a, back), 0;
if (a % 2 && c % 2) return cout << max(a, c), 0;
if (c % 2 && back % 2) return cout << max(c, back), 0;
if (a % 2) return cout << max(back, c), 0;
if (back % 2) return cout << max(c, a), 0;
if (c % 2) return cout << max(a, back), 0;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
long long a, b, c;
int ua, ub, uc;
scanf("%I64d%I64d%I64d", &a, &b, &c);
if (a > b) swap(a, b);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
ua = a % 2, ub = b % 2, uc = c % 2;
if (ua == ub && ub == uc)
printf("%I64d\n", b);
else if (ua == ub)
printf("%I64d\n", max(a, b));
else if (ub == uc)
printf("%I64d\n", max(b, c));
else
printf("%I64d\n", max(a, c));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
scanf("%I64d %I64d %I64d", &a[0], &a[1], &a[2]);
sort(a, a + 3);
if ((a[1] - a[0]) % 2 == 0)
printf("%I64d\n", a[1]);
else
printf("%I64d\n", a[2]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
void ran() { srand(chrono::steady_clock::now().time_since_epoch().count()); }
long long get_rand() {
long long a = rand();
long long b = rand();
return a * (RAND_MAX + 1ll) + b;
}
signed main() {
ran();
fast();
long long arr[3];
for (long long i = 0; i < 3; i++) cin >> arr[i];
sort(arr, arr + 3);
if (arr[1] % 2 == arr[0] % 2)
cout << arr[1] << endl;
else
cout << arr[2] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
long long wyn;
int main() {
wyn = 1000000000;
wyn *= wyn;
scanf("%lld%lld%lld", &a, &b, &c);
if ((a & 1) == (b & 1)) wyn = min(wyn, max(a, b));
if ((a & 1) == (c & 1)) wyn = min(wyn, max(a, c));
if ((c & 1) == (b & 1)) wyn = min(wyn, max(c, b));
printf("%lld\n", wyn);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void mSwap(unsigned int* a, unsigned int* b) {
*a = *a ^ *b;
*b = *a ^ *b;
*a = *a ^ *b;
}
void mSort(unsigned int* a, unsigned int* b, unsigned int* c) {
if (*a < *b) {
mSwap(a, b);
}
if (*c > *a) {
mSwap(a, c);
mSwap(b, c);
} else if (*c > *b) {
mSwap(b, c);
}
}
int main() {
unsigned int a, b, c, sum = 0;
cin >> a >> b >> c;
mSort(&a, &b, &c);
if ((b - c) % 2) {
cout << a << endl;
} else
cout << b << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double INF = 1000 * 1000 * 1000 + 7;
long long calc(long long a, long long b, long long c) {
long long M, m;
long long res = 0;
M = max(a, b);
m = min(a, b);
res += m;
c += m;
if (c % 2 == 0)
res += min(M - m, c);
else
res += M - m;
return res;
}
int main() {
long long a, b, c;
while (cin >> a >> b >> c) {
long long res = a + b + c - 1;
if ((a + b) % 2 == 0) {
res = min(res, calc(a, b, c));
}
if ((b + c) % 2 == 0) {
res = min(res, calc(b, c, a));
}
if ((c + a) % 2 == 0) {
res = min(res, calc(c, a, b));
}
cout << res << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e9 + 5;
int main() {
long long a, b, c;
long long answer;
cin >> a >> b >> c;
if (a > b) swap(a, b);
if (b > c) swap(b, c);
if (a > b) swap(a, b);
if (c % 2 == b % 2) answer = c;
if (c % 2 == a % 2) answer = c;
if (b % 2 == a % 2) answer = b;
cout << answer << '\n';
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
long long clever(long long a, long long b, long long c) {
vector<long long> t;
t.push_back(a);
t.push_back(b);
t.push_back(c);
sort((t).begin(), (t).end());
long long ans = INF64;
do {
if ((t[0] + t[1]) % 2 == 0) {
long long need =
(((t[0] - t[1]) >= 0) ? (t[0] - t[1]) : (-(t[0] - t[1]))) / 2;
long long n2 = max(0LL, need - t[2]), n1 = need - n2;
long long cur = n1 + n2 + (t[0] + t[1]) / 2;
ans = min(ans, cur);
}
} while (next_permutation((t).begin(), (t).end()));
return ans;
}
int main() {
long long a, b, c;
cin >> a >> b >> c;
long long ans = clever(a, b, c);
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline bool SR(int &x) { return scanf("%d", &x) == 1; }
inline bool SR(long long &x) { return scanf("%lld", &x) == 1; }
inline bool SR(double &x) { return scanf("%lf", &x); }
inline bool SR(char *s) { return scanf("%s", s); }
inline bool RI() { return 1; }
template <typename I, typename... T>
bool RI(I &x, T &...tail) {
return SR(x) && RI(tail...);
}
inline void SP(const int x) { printf("%d", x); }
inline void SP(const long long x) { printf("%lld", x); }
inline void SP(const double x) { printf("%.10f", x); }
inline void SP(const char *s) { printf("%s", s); }
inline void PL() { puts(""); }
template <typename I, typename... T>
void PL(const I x, const T... tail) {
SP(x);
if (sizeof...(tail)) putchar(' ');
PL(tail...);
}
template <typename I>
inline void _DOING(const char *s, I &&x) {
cerr << s << " = " << x << '\n';
}
template <typename I, typename... T>
void _DOING(const char *s, I &&x, T &&...tail) {
int c = 0;
while (*s != ',' || c != 0) {
if (*s == '(' || *s == '[' || *s == '{') c++;
if (*s == ')' || *s == ']' || *s == '}') c--;
cerr << *s++;
}
cerr << " = " << x << " , ";
_DOING(s + 1, tail...);
}
const int INF = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3fll;
inline int RAND() {
static int x = 880301;
return x = (x * 0xdefacedll + 1ll) % 0x7fffffffll;
}
long long f(long long a, long long b, long long c) {
if ((b + c) & 1)
return a + b + c - 1;
else
return max(b, c);
}
int main() {
long long a, b, c;
RI(a, b, c);
long long ans = a + b + c - 1;
ans = min(ans, f(a, b, c));
ans = min(ans, f(b, a, c));
ans = min(ans, f(c, a, b));
PL(ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
<< endl;
}
int main() {
long long int a, b, c, d1, d2, d3, ans, v, i, j, k;
while (scanf("%lld %lld %lld", &a, &b, &c) == 3) {
ans = 100000000000;
d1 = abs(a - b);
d2 = abs(b - c);
d3 = abs(c - a);
if (!(d1 & 1) and max(a, b) < ans) {
ans = max(a, b);
}
if (!(d2 & 1) and max(b, c) < ans) {
ans = max(b, c);
}
if (!(d3 & 1) and max(c, a) < ans) {
ans = max(c, a);
}
printf("%lld\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, b, c, mx = pow(2, 32);
cin >> a >> b >> c;
if (abs(a - b) % 2 == 0) mx = min(mx, max(a, b));
if (abs(a - c) % 2 == 0) mx = min(mx, max(a, c));
if (abs(c - b) % 2 == 0) mx = min(mx, max(b, c));
cout << mx << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
inline int addmod(int x, int y) {
return (x % 1000000007 + y % 1000000007) % 1000000007;
}
inline int submod(int x, int y) {
return (x % 1000000007 - y % 1000000007 + 1000000007) % 1000000007;
}
inline int mulmod(int x, int y) {
return (x % 1000000007 * 1LL * y % 1000000007) % 1000000007;
}
inline int nextSubMask(int i, int mask) { return (i - 1) & mask; }
void we_r_done() {
cout << "NO";
exit(0);
}
void debug(bool ok, string mssg) {
if (ok) return;
cout << mssg;
exit(0);
}
long long int solve(long long int a, long long int b, long long int c) {
if (a > b) swap(a, b);
if ((b - a) % 2) return -1;
return b;
}
int main() {
long long int a, b, c;
cin >> a >> b >> c;
long long int ans = solve(a, b, c);
if (solve(a, c, b) != -1)
ans = (ans == -1 ? solve(a, c, b) : min(ans, solve(a, c, b)));
if (solve(c, b, a) != -1)
ans = (ans == -1 ? solve(c, b, a) : min(ans, solve(c, b, a)));
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
unsigned a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[1] - a[0]) % 2) {
if (!((a[2] - a[1]) % 2))
rotate(a, a + 1, a + 3);
else
swap(a[1], a[2]);
}
unsigned count = a[0];
a[2] += a[0];
a[1] -= a[0];
a[0] = 0;
count += a[1];
cout << count << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[0] + a[1]) % 2 == 0) {
cout << a[1];
} else
cout << a[2];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = 0;
c = getchar();
}
while (c >= '0' && c <= '9')
x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
return f ? x : -x;
}
long long a[5];
signed main() {
for (long long i = 0; i < 3; i++) a[i] = read();
sort(a, a + 3);
if (((a[1] - a[0]) & 1) == 0)
printf("%lld", a[1]);
else
printf("%lld", a[2]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
ios::sync_with_stdio(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[0] + a[1]) % 2)
cout << a[2] << endl;
else
cout << a[1] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1029384756;
const double PI = acos(-1);
const double EPS = 0.0000000304;
pair<long long, int> ip[3];
int main() {
scanf("%I64d%I64d%I64d", &ip[0].first, &ip[1].first, &ip[2].first);
ip[0].second = 0;
ip[1].second = 1;
ip[2].second = 2;
sort(ip, ip + 3);
if ((ip[0].first % 2) == (ip[1].first % 2) &&
(ip[1].first % 2) == (ip[2].first % 2)) {
long long t = ip[1].first;
printf("%I64d", t);
} else if (ip[0].first % 2 == ip[1].first % 2) {
printf("%I64d", ip[1].first);
} else if (ip[1].first % 2 == ip[2].first % 2) {
printf("%I64d", ip[2].first);
} else {
printf("%I64d", ip[2].first);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
scanf("%I64d%I64d%I64d", &a[0], &a[1], &a[2]);
long long ans = a[0] + a[1] + a[2];
for (int i = 0; i <= 2; i++) {
long long A = a[i], B = a[(i + 1) % 3];
if (((A - B) < 0 ? -(A - B) : (A - B)) & 1) continue;
ans =
((ans) < (((A) > (B) ? (A) : (B))) ? (ans) : (((A) > (B) ? (A) : (B))));
}
printf("%I64d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long a, b, c, best = 1LL << 60;
cin >> a >> b >> c;
if (a % 2 == b % 2) best = min(best, max(a, b));
if (c % 2 == b % 2) best = min(best, max(c, b));
if (a % 2 == c % 2) best = min(best, max(a, c));
if (best == 1LL << 60) best = -1;
cout << best << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long arr[5];
int main() {
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if ((arr[1] - arr[0]) % 2 == 0) {
cout << arr[1] << endl;
} else
cout << arr[2] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<long long> nums(3);
for (int i = 0; i < 3; i++) cin >> nums[i];
sort(nums.begin(), nums.end());
if (nums[0] % 2 == nums[1] % 2)
cout << nums[1];
else
cout << nums[2];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e) {
cout << "-->" << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
cout << "-->" << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
cout << "-->" << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
cout << "-->" << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
cout << "-->" << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5
<< endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
cout << "-->" << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " "
<< e6 << endl;
}
int main() {
long long a[5];
while (scanf("%lld %lld %lld", &a[0], &a[1], &a[2]) == 3) {
sort(a, a + 3);
printf("%lld\n", !((a[0] + a[1]) % 2) ? a[1] : a[2]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1111111;
const long long INF = 0x7FFFFFFFFFFFFFFFLL;
string s;
map<pair<pair<int, int>, int>, long long> mpp;
long long get(long long a, long long b, long long c) {
pair<pair<int, int>, int> p = make_pair(make_pair(a, b), c);
if (mpp.find(p) != mpp.end()) return mpp[p];
if (a + b == 0 || b + c == 0 || a + c == 0) return 0;
int ma = min(a, b);
int mb = min(a, c);
int mc = min(b, c);
long long aa = INF, bb = INF, cc = INF;
if (ma) aa = get(a - ma, b - ma, c + ma) + ma;
if (mb) bb = get(a - mb, b + mb, c - mb) + mb;
if (mc) cc = get(a + mc, b - mc, c - mc) + mc;
long long ret = min(min(aa, bb), cc);
if ((b + c) % 2 == 0) {
long long v = max(b, c) - (b + c) / 2;
if (a >= v) {
if (b > c) {
ret = min(ret, get(a - v, b - v, c + v) + v);
} else if (b < c) {
ret = min(ret, get(a - v, b + v, c - v) + v);
}
}
}
if ((a + c) % 2 == 0) {
long long v = max(a, c) - (a + c) / 2;
if (b >= v) {
if (a > c) {
ret = min(ret, get(a - v, b - v, c + v) + v);
} else if (a < c) {
ret = min(ret, get(a + v, b - v, c - v) + v);
}
}
}
if ((a + b) % 2 == 0) {
long long v = max(a, b) - (a + b) / 2;
if (c >= v) {
if (a > b) {
ret = min(ret, get(a - v, b + v, c - v) + v);
} else if (a < b) {
ret = min(ret, get(a + v, b - v, c - v) + v);
}
}
}
return mpp[p] = ret;
}
int main() {
long long a, b, c;
while (cin >> a >> b >> c) {
if (a > b) swap(a, b);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
if ((a + b) % 2 == 1) {
cout << c << endl;
} else {
cout << b << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:200000000")
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
map<vector<long long>, long long> z;
long long rec(vector<long long> a) {
sort(a.begin(), a.end());
if (z.count(a)) return z[a];
for (int i = 0; i < (int)(2); i++)
if (a[i] == a[i + 1]) return a[i];
long long res = INF64;
if (a[0]) {
vector<long long> b(a);
long long t = b[0];
b[0] -= t;
b[1] -= t;
b[2] += t;
res = min(res, t + rec(b));
}
if (a[0]) {
vector<long long> b(a);
long long t = min(b[0], (b[2] - b[1] + 1) / 2);
b[0] -= t;
b[2] -= t;
b[1] += t;
res = min(res, t + rec(b));
}
if (a[1]) {
vector<long long> b(a);
long long t = min(b[1], (b[1] - b[0] + 1) / 2);
b[1] -= t;
b[2] -= t;
b[0] += t;
res = min(res, t + rec(b));
}
return z[a] = res;
}
long long solve(vector<long long> a) {
sort(a.begin(), a.end());
if (int(a[0] % 2 != a[2] % 2) + int(a[1] % 2 != a[2] % 2) == 1)
return a[2];
else
return a[1];
}
int main() {
vector<long long> a(3);
for (int i = 0; i < (int)(3); i++) cin >> a[i];
long long res = solve(a);
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int num[105];
int main() {
cin >> num[0] >> num[1] >> num[2];
sort(num, num + 3);
if (num[0] == num[1]) {
cout << num[0] << endl;
} else {
if ((num[1] - num[0]) % 2 == 0) {
cout << (num[1] - num[0]) / 2 + (num[1] + num[0]) / 2 << endl;
} else {
if (num[2] == num[1])
cout << num[2] << endl;
else {
if ((num[2] - num[1]) % 2 == 0) {
cout << (num[2] - num[1]) / 2 + (num[2] + num[1]) / 2 << endl;
} else {
if ((num[2] - num[0]) % 2 == 0) {
cout << (num[2] - num[0]) / 2 + (num[2] + num[0]) / 2 << endl;
} else {
cout << num[2] + num[1] + num[0] - 1 << endl;
}
}
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3], res;
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
res = (long long)1e10;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (a[i] % 2 == a[j] % 2 && i != j) res = min(res, max(a[i], a[j]));
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int c[3];
long long int ans = 200000000000000000LL;
cin >> c[0] >> c[1] >> c[2];
sort(c, c + 3);
if ((c[1] - c[0]) % 2 == 0) {
ans = min(ans, c[1]);
}
if ((c[2] - c[0]) % 2 == 0) {
ans = min(ans, c[2]);
}
if ((c[2] - c[1]) % 2 == 0) {
ans = min(ans, c[2]);
}
if (ans == 200000000000000000LL)
cout << -1 << endl;
else
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long cal(long long a, long long b, long long c) {
long long ans = 0;
if (b < c) swap(b, c);
ans += c;
b -= c;
if (b & 1)
ans = 1000000000000LL;
else
ans += b;
return ans;
}
int main() {
long long ans = 1000000000000LL, a, b, c;
cin >> a >> b >> c;
ans = min(ans, cal(a, b, c));
ans = min(ans, cal(b, a, c));
ans = min(ans, cal(c, b, a));
if (ans == 1000000000000LL)
cout << -1;
else
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ans = 0, a, b, c;
void work(long long a, long long b, long long c) {
if (b < c) swap(b, c);
b -= c;
a += c;
if (b & 1)
ans = max(ans, 1ll);
else
ans = max(ans, a);
}
int main() {
scanf("%I64d%I64d%I64d", &a, &b, &c);
work(a, b, c);
work(b, a, c);
work(c, a, b);
printf("%I64d\n", a + b + c - ans);
}
|
#include <bits/stdc++.h>
using namespace std;
long long x, y, z;
long long a[4];
long long read() {
long long x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return x * f;
}
signed main() {
a[1] = read(), a[2] = read(), a[3] = read();
sort(a + 1, a + 4);
if ((a[2] & 1) == (a[1] & 1))
cout << a[2] << endl;
else
cout << a[3] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 50;
long long chk(long long A, long long B, long long C) {
if ((A + B) % 2) return INF;
return abs(A - B) / 2 + (A + B) / 2;
}
int main(void) {
long long a, b, c;
scanf("%I64d%I64d%I64d", &a, &b, &c);
long long res = chk(a, b, c);
res = min(res, chk(b, c, a));
res = min(res, chk(c, a, b));
printf("%I64d\n", res);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
return x > 0 ? x : -x;
}
template <class T>
T sqr(T x) {
return x * x;
}
const long long inf = (long long)(1E15);
long long calc(long long a1, long long a2, long long a3) {
long long d23 = a2 + a3;
if (d23 % 2LL == 1LL) return inf;
d23 /= 2LL;
long long delta = abs(a2 - d23);
return delta + d23;
}
int main() {
long long a[3];
for (int i = 0; i < 3; ++i) cin >> a[i];
long long res = inf;
for (int it = 0; it < 3; ++it) {
res = min(res, calc(a[0], a[1], a[2]));
swap(a[0], a[(it + 1) % 3]);
}
if (res == inf) res = -1;
cout << res << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using db = double;
ll a, b, c;
ll cal(ll a, ll b) {
if (a % 2 == b % 2) return max(a, b);
return LLONG_MAX;
}
int main() {
cin >> a >> b >> c;
cout << min({cal(a, b), cal(b, c), cal(a, c)}) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long oo = 1LL << 50;
long long cal(long long a, long long b, long long c) {
if (b < c) swap(b, c);
long long ans = c;
a += ans;
b -= ans;
c -= ans;
if (b % 2 != 0) return oo;
if (a == 0) return oo;
return ans + b;
}
int main() {
long long a, b, c;
while (~scanf("%I64d %I64d %I64d", &a, &b, &c)) {
long long ans = oo;
ans = min(ans, cal(a, b, c));
ans = min(ans, cal(b, a, c));
ans = min(ans, cal(c, a, b));
printf("%I64d\n", ans);
}
}
|
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return x * f;
}
signed main() {
long long a = read(), b = read(), c = read();
if (b > c) swap(b, c);
if (a > b) swap(a, b);
if (b > c) swap(b, c);
if ((b - a) % 2)
printf("%lld", c);
else
printf("%lld", b);
return 0;
}
|
#include <bits/stdc++.h>
int main() {
long long int a, b, c, x, y, z;
scanf("%I64d%I64d%I64d", &a, &b, &c);
x = (a > b && a > c) ? a : b > c ? b : c;
y = (a < b && a < c) ? a : b < c ? b : c;
z = a + b + c - x - y;
if ((z - y) % 2)
printf("%I64d\n", x);
else
printf("%I64d\n", z);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long work(long long a, long long b, long long c) {
long long ans = 0;
long long p = min(a, b);
c += p;
ans += p;
a -= p;
b -= p;
if (b == 0) b = a;
if (b & 1) return -1;
if (c == 0) return -1;
ans += b;
return ans;
}
int main() {
long long a[3];
cin >> a[0] >> a[1] >> a[2];
long long ans = -1;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
if (i != j) {
long long now = work(a[i], a[j], a[3 - i - j]);
if (now == -1) continue;
if (ans == -1 || now < ans) ans = now;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
long long int ans = 0;
if ((a[1] - a[0]) % 2 == 0) {
ans = a[1];
} else
ans = a[2];
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000000 + 7;
int bs(int *st, int *en, int val, char c) {
int k;
if (c == 'l') k = lower_bound(st, en, val) - st;
if (c == 'u') k = upper_bound(st, en, val) - st;
return k;
}
int prime[780500];
int sieve() {
int a, b, c;
c = 0;
prime[c] = 2;
bool *m = (bool *)calloc(1000006, sizeof(bool));
for (a = 3; a <= 1000000; a = a + 2) {
if (!m[a]) {
prime[++c] = a;
for (b = 2 * a; b <= 1000000; b = b + a) m[b] = true;
}
}
free(m);
return c;
}
vector<long long> primes;
const int N = 15000000;
int lp[N + 1];
void genPrimes() {
primes.reserve(N / 10);
for (int i = 2; i <= N; ++i) {
if (lp[i] == 0) {
lp[i] = i;
primes.push_back(i);
}
for (int j = 0; j < primes.size(); j++) {
int p = primes[j];
int q = i * p;
if (q > N || p > lp[i]) {
break;
}
lp[q] = p;
}
}
}
long long bigmod(long long a, long long n) {
n %= mod - 1;
long long res = 1;
while (n) {
if (n & 1ll) {
res = res * a;
if (res >= mod) {
res %= mod;
}
}
a = a * a;
if (a >= mod) {
a %= mod;
}
n >>= 1;
}
return res;
}
int main() {
long long a, b, c, d, e, x, y, z;
long long A, B, C;
cin >> A >> B >> C;
x = 0;
if (!A) x++;
if (!B) x++;
if (!C) x++;
if (x >= 2) {
printf("0\n");
return 0;
}
x = 0;
if (A == B) x++;
if (B == C) x++;
if (C == A) x++;
if (x >= 1) {
if (A == B) x = A;
if (B == C) x = B;
if (C == A) x = C;
cout << x << endl;
return 0;
}
z = 0;
vector<long long> v;
v.clear();
v.push_back(A);
v.push_back(B);
v.push_back(C);
sort(v.begin(), v.end());
C = v[0];
B = v[1];
A = v[2];
if (C) z = z + C;
y = B - C;
A = A + C;
x = A / (B - C);
z = z + x * y;
z = z + (A % (B - C));
C = v[0];
B = v[1];
A = v[2];
if ((B - C) % 2 == 0) {
z = min(z, B);
}
if ((A - B) % 2 == 0) {
x = (A - B) / 2;
z = min(z, A);
}
if ((A - C) % 2 == 0) {
x = (A - C) / 2;
z = min(z, A);
}
cout << z << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
long long a[4];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[1] - a[0]) % 2 == 0)
cout << a[1] << endl;
else
cout << a[2] << endl;
return 0;
}
|
#include <bits/stdc++.h>
long long a, b, c, Ans, Now;
void GetAns(long long a, long long b, long long c) {
if ((a + b) & 1) return;
if (a < b) a ^= b ^= a ^= b;
a -= b;
Now = 1ll * a + 1ll * b;
if (Ans == -1 || Now < Ans) Ans = Now;
}
int main() {
scanf("%I64d%I64d%I64d", &a, &b, &c);
Ans = -1;
GetAns(a, b, c);
GetAns(c, b, a);
GetAns(c, a, b);
printf("%I64d\n", Ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int intmax = 0x3f3f3f3f;
double eps = 1e-6;
template <class T>
inline void checkmin(T &a, T b) {
if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
return x * x;
}
template <class T>
inline T lowbit(T n) {
return (n ^ (n - 1)) & n;
}
template <class T>
inline int countbit(T n) {
return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
inline T checkmod(T n, T m) {
return (n % m + m) % m;
}
inline int rand(int a, int b) {
if (a >= b) return a;
return rand() % (b - a) + a;
}
template <class T>
inline T gcd(T a, T b) {
if (a < 0) return gcd(-a, b);
if (b < 0) return gcd(a, -b);
return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
if (a < 0) return lcm(-a, b);
if (b < 0) return lcm(a, -b);
return a * (b / gcd(a, b));
}
template <class T>
inline T euclid(T a, T b, T &x, T &y) {
if (a < 0) {
T d = euclid(-a, b, x, y);
x = -x;
return d;
}
if (b < 0) {
T d = euclid(a, -b, x, y);
y = -y;
return d;
}
if (b == 0) {
x = 1;
y = 0;
return a;
} else {
T d = euclid(b, a % b, x, y);
T t = x;
x = y;
y = t - (a / b) * y;
return d;
}
}
template <class T>
inline vector<pair<T, int> > factorize(T n) {
vector<pair<T, int> > R;
for (T i = 2; n > 1;) {
if (n % i == 0) {
int C = 0;
for (; n % i == 0; C++, n /= i)
;
R.push_back(make_pair(i, C));
}
i++;
if (i > n / i) i = n;
}
if (n > 1) R.push_back(make_pair(n, 1));
return R;
}
template <class T>
inline bool isPrimeNumber(T n) {
if (n <= 1) return false;
for (T i = 2; i * i <= n; i++)
if (n % i == 0) return false;
return true;
}
template <class T>
inline T eularFunction(T n) {
vector<pair<T, int> > R = factorize(n);
T r = n;
for (int i = 0; i < R.size(); i++) r = r / R[i].first * (R[i].first - 1);
return r;
}
template <class T>
inline int dblcmp(T a, const T b) {
a -= b;
return a > eps ? 1 : (a < -eps ? -1 : 0);
}
template <class T>
inline int sgn(T a) {
return a > eps ? 1 : (a < -eps ? -1 : 0);
}
struct vec2 {
double x, y;
vec2(double x = 0.0, double y = 0.0) : x(x), y(y) {}
vec2 operator+(const vec2 &b) const { return vec2(x + b.x, y + b.y); }
vec2 operator-(const vec2 &b) const { return vec2(x - b.x, y - b.y); }
vec2 operator*(const double &b) const { return vec2(x * b, y * b); }
vec2 operator/(const double &b) const { return vec2(x / b, y / b); }
double operator*(const vec2 &b) const { return x * b.x + y * b.y; }
double operator^(const vec2 &b) const { return x * b.y - y * b.x; }
double len() { return sqrt(x * x + y * y); }
vec2 unit() { return *this / len(); }
vec2 rotate(double r) {
vec2 t(sin(r), cos(r));
return vec2(*this ^ t, *this * t);
}
bool operator<(const vec2 &b) const {
if (dblcmp(x, b.x) != 0)
return dblcmp(x, b.x) < 0;
else
return dblcmp(y, b.y) < 0;
}
};
int main() {
long long a, b, c, ans;
while (cin >> a >> b >> c) {
ans = a + b + c + 10;
if ((a & 1) == (b & 1)) checkmin(ans, max(a, b));
if ((a & 1) == (c & 1)) checkmin(ans, max(a, c));
if ((b & 1) == (c & 1)) checkmin(ans, max(b, c));
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a[3], i, total = 0;
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[0] + a[1]) % 2 == 0) {
cout << a[1] << endl;
return 0;
}
cout << a[2];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[0] % 2) == (a[1] % 2))
cout << a[1] << "\n";
else
cout << a[2] << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long Inf = 1e15;
int main() {
long long a, b, c;
scanf("%lld %lld %lld", &a, &b, &c);
long long ans = Inf;
if ((a + b) % 2 == 0) ans = max(a, b);
if ((a + c) % 2 == 0) ans = min(max(a, c), ans);
if ((b + c) % 2 == 0) ans = min(max(b, c), ans);
if (ans == Inf)
puts("-1");
else
printf("%I64d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long A[3];
int main() {
cin >> A[0] >> A[1] >> A[2];
sort(A, A + 3);
if ((A[1] - A[0]) % 2 == 0)
cout << A[1] << endl;
else
cout << A[2] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1ll << 50;
long long a[3], b[3];
int main() {
long long mn = INF;
cin >> a[0] >> a[1] >> a[2];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) b[j] = a[j];
swap(b[i], b[0]);
if (b[1] < b[2]) swap(b[1], b[2]);
if ((b[1] - b[2]) % 2 == 0) mn = min(mn, b[1]);
}
if (mn == INF)
cout << -1 << endl;
else
cout << mn << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long INF = INT64_MAX;
long long a, b, c;
long long f(long long x, long long y) {
if (x % 2 != y % 2)
return INF;
else
return max(x, y);
}
signed main() {
cin >> a >> b >> c;
if ((!a && !b) || (!b && !c) || (!a && !c))
cout << 0;
else
cout << min(f(a, b), min(f(b, c), f(a, c)));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int num[100010];
int main() {
long long ara[5];
cin >> ara[0] >> ara[1] >> ara[2];
sort(ara, ara + 3);
if (ara[1] == 0) {
cout << 0;
return 0;
}
if ((ara[0] + ara[1]) % 2 == 0) {
cout << ara[1];
} else {
cout << ara[2];
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[0] + a[1]) % 2 == 0)
cout << a[1];
else
cout << a[2];
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long nums[3];
cin >> nums[0] >> nums[1] >> nums[2];
sort(nums, nums + 3);
if ((nums[1] - nums[0]) % 2 != 0) {
cout << nums[2] << endl;
} else {
cout << nums[1] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
long long data[5];
int main() {
long long ans = 10000000000;
while (cin >> a >> b >> c) {
if ((a + b) % 2 == 0) ans = min(ans, max(a, b));
if ((a + c) % 2 == 0) ans = min(ans, max(a, c));
if ((c + b) % 2 == 0) ans = min(ans, max(c, b));
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
int main() {
long long int a, b, c, high, low, mid;
scanf("%I64d %I64d %I64d", &a, &b, &c);
high = a > (b > c ? b : c) ? a : b > c ? b : c;
low = a < (b < c ? b : c) ? a : b < c ? b : c;
mid = (a + b + c) - (high + low);
if ((mid - low) % 2 == 0)
printf("%I64d", mid);
else
printf("%I64d", high);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
long long mod = 1000000007LL;
long long mod2 = 998244353LL;
int t, n, k;
long long a, b, c;
int main() {
cin >> a >> b >> c;
vector<long long> v = {a, b, c};
sort(v.begin(), v.end());
if (v[0] % 2 == 0) {
if (v[1] % 2 == 0) {
cout << v[1] << endl;
} else {
cout << v[2] << endl;
}
} else {
if (v[1] % 2 == 0) {
cout << v[2] << endl;
} else {
cout << v[1] << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
const int MAX = 1e3 + 5, MOD = 998244353;
const int MAXLOG = log2(MAX) + 5;
const int MAXN = 1e9 + 5;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector<long long> v;
for (int i = 0; i < 3; i++) {
long long x;
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
if ((v[1] - v[0]) % 2 == 1)
cout << v[2];
else
cout << v[1];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a[4], i;
for (i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if ((a[1] - a[0]) % 2)
cout << a[2];
else
cout << a[1];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
scanf("%I64d%I64d%I64d", &a[0], &a[1], &a[2]);
long long ans = a[0] + a[1] + a[2];
int i;
for (i = 0; i < 3; i++) {
if ((a[i] + a[(i + 1) % 3]) % 2 == 0)
ans = min(ans, max(a[i], a[(i + 1) % 3]));
}
printf("%I64d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a[5];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if ((a[1] - a[0]) % 2 == 0)
cout << a[1] << endl;
else
cout << a[2] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<long long> fuck;
bool judge() {
for (auto c : fuck) {
if (c % 2 == 0 && c >= 0) return true;
}
return false;
}
int main() {
long long a, b, c;
cin >> a >> b >> c;
fuck.push_back(a - c);
fuck.push_back(b - c);
fuck.push_back(b - a);
fuck.push_back(c - a);
fuck.push_back(a - b);
fuck.push_back(c - b);
if (!judge()) {
cout << -1 << endl;
} else {
long long min1 = 9223372036854775807LL;
if (fuck[0] % 2 == 0 && fuck[0] >= 0) {
min1 = min(min1, a);
}
if (fuck[1] % 2 == 0 && fuck[1] >= 0) {
min1 = min(min1, b);
}
if (fuck[2] % 2 == 0 && fuck[2] >= 0) {
min1 = min(min1, b);
}
if (fuck[3] % 2 == 0 && fuck[3] >= 0) {
min1 = min(min1, c);
}
if (fuck[4] % 2 == 0 && fuck[4] >= 0) {
min1 = min(min1, a);
}
if (fuck[5] % 2 == 0 && fuck[5] >= 0) {
min1 = min(min1, c);
}
cout << min1 << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c, ans = LLONG_MAX;
cin >> a >> b >> c;
if ((a - b) % 2 == 0) ans = min(ans, max(a, b));
if ((a - c) % 2 == 0) ans = min(ans, max(a, c));
if ((c - b) % 2 == 0) ans = min(ans, max(b, c));
if (ans == INT_MAX) ans = -1;
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long b[4], a = 0;
for (int i = 0; i < 3; i++) cin >> b[i], a += b[i];
a--;
for (int i = 0; i < 3; i++)
for (int j = i + 1; j < 3; j++)
if (abs(b[i] - b[j]) % 2 == 0) a = min(a, max(b[i], b[j]));
cout << a;
return 0;
}
|
#include <bits/stdc++.h>
int main() {
long long int a, b, c, t;
scanf("%I64d%I64d%I64d", &a, &b, &c);
if (a > b) {
t = a;
a = b;
b = t;
}
if (b > c) {
t = b;
b = c;
c = t;
}
if (a > b) {
t = a;
a = b;
b = t;
}
if (a == 0 && b == 0)
printf("0");
else {
if ((b - a) % 2 == 0)
printf("%I64d", b);
else
printf("%I64d", c);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long base = 2e9 + 4257;
const long long mod = 998244353;
const long long mod2 = 1e9 + 4233;
const long double eps = 1e-5;
const long long maxn = 1e9 + 9;
const long double pi = acos(-1);
const long long delta = 1e5 + 7;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
long long n, m, k, res;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m >> k;
res = n + m + k;
if ((n + m) % 2 == 0) {
res = min(res, max(n, m));
}
if ((n + k) % 2 == 0) {
res = min(res, max(n, k));
}
if ((k + m) % 2 == 0) {
res = min(res, max(k, m));
}
cout << res << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
inline long long calc(long long a, long long b, long long c) {
if (a < b) swap(a, b);
a -= b;
c += b;
long long Cnt = b;
b = 0;
if (c == 0) return 1e18;
if (a & 1) return 1e18;
return Cnt + a;
}
int main() {
long long a, b, c;
cin >> a >> b >> c;
long long res = min({calc(a, b, c), calc(a, c, b), calc(b, c, a)});
if (res == 1e18)
cout << -1;
else
cout << res;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool uax(T &x, T y) {
return (y > x) ? x = y, true : false;
}
template <typename T>
inline bool uin(T &x, T y) {
return (y < x) ? x = y, true : false;
}
string to_string(char c) { return "'" + string(1, c) + "'"; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool f = false;
string r = "{";
for (auto x : v) {
if (f) r += ", ";
r += to_string(x);
f = true;
}
return r += "}";
}
template <typename A>
string to_string(vector<vector<A>> v) {
string r;
for (auto x : v) r += "\n" + to_string(x);
return r;
}
void err(istream_iterator<string>) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " =: " << to_string(a) << "; ";
err(++it, args...);
}
template <typename T>
void kek(T ans) {
cout << ans << endl;
exit(0);
}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
long long solve(long long x, long long a, long long b) {
if ((a + b) & 1) return INF;
if (a > b) swap(a, b);
return b;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long a, b, c;
cin >> a >> b >> c;
long long ans = INF;
uin(ans, solve(a, b, c));
uin(ans, solve(b, a, c));
uin(ans, solve(c, b, a));
if (ans == INF) ans = -1;
kek(ans);
}
|
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const long long oo = 1000111000111000111LL;
long long check(long long a, long long b, long long c) {
if (a > b) swap(a, b);
long long res = a;
c += a;
b -= a;
a -= a;
if (b % 2 == 1) return oo;
if (c == 0) return oo;
res += b;
return res;
}
int main() {
long long a, b, c;
cin >> a >> b >> c;
long long res = oo;
res = min(res, check(a, b, c));
res = min(res, check(b, c, a));
res = min(res, check(c, a, b));
if (res == oo) res = -1;
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
int main() {
long long int a[3], i, j, k;
for (i = 0; i < 3; i++) scanf("%I64d", &a[i]);
for (i = 0; i < 2; i++)
for (j = i + 1; j < 3; j++) {
if (a[i] > a[j]) {
k = a[i];
a[i] = a[j];
a[j] = k;
}
}
if ((a[1] - a[0]) % 2)
printf("%I64d", a[2]);
else
printf("%I64d", a[1]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long a, b, c, best = 1LL << 60;
cin >> a >> b >> c;
if (a % 2 == b % 2) best = min(best, min(a, b) + (max(a, b) * 2 - a - b));
if (c % 2 == b % 2) best = min(best, min(c, b) + (max(c, b) * 2 - c - b));
if (a % 2 == c % 2) best = min(best, min(a, c) + (max(a, c) * 2 - a - c));
if (best == 1LL << 60) best = -1;
cout << best << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long A, B, C;
cin >> A >> B >> C;
if (A < B) swap(A, B);
if (A < C) swap(A, C);
if (B < C) swap(B, C);
cout << (((B ^ C) & 1) ? A : B) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long kInf = 0x3f3f3f3f3f3f3f3fLL;
long long test(long long a, long long b, long long c) {
if (b < c) swap(b, c);
long long delta = b - c;
if ((delta & 1)) return kInf;
long long ret = 0;
long long k = delta / 2 - a;
b -= 2 * k;
ret += 2 * k;
delta = b - c;
ret += delta / 2 + (b + c) / 2;
return ret;
}
int main() {
long long a, b, c;
cin >> a >> b >> c;
long long ans = kInf;
ans = min(ans, test(a, b, c));
ans = min(ans, test(b, a, c));
ans = min(ans, test(c, a, b));
if (ans == kInf)
cout << -1 << '\n';
else
cout << ans << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
while (cin >> a >> b >> c) {
if (a < b) {
long long t = a;
a = b;
b = t;
}
if (a < c) {
long long t = a;
a = c;
c = t;
}
if (b < c) {
long long t = b;
b = c;
c = t;
}
if (b % 2 == c % 2)
cout << b << endl;
else
cout << a << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long s[10];
int main() {
cin >> s[0] >> s[1] >> s[2];
sort(s, s + 3);
if ((s[1] - s[0]) % 2 == 0) {
cout << s[1] << endl;
} else {
cout << s[2] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1020;
const int maxm = 2000020;
const long long mod = 100007;
const int inf = 0x37373737;
const double pi = acos(-1);
bool flag = true;
long long getAns(long long a, long long b, long long c) {
if (a < b) return getAns(b, a, c);
long long ans;
if (b != 0) {
ans = getAns(a - b, 0, c + b);
if (ans != -1)
return ans + b;
else
return -1;
}
if (a & 1 || c == 0) {
return -1;
}
if (a / 2 <= c)
return a;
else {
int k;
k = floor((a - 0.5) / (4 * c)) + 1;
return getAns(a - 2 * c * k, 0, c) + 2 * c * k;
}
}
int main() {
long long a, b, c;
cin >> a >> b >> c;
long long ans = a + b + c + 100;
long long ans1 = getAns(a, b, c);
long long ans2 = getAns(a, c, b);
long long ans3 = getAns(b, c, a);
if (ans1 != -1) ans = min(ans, ans1);
if (ans2 != -1) ans = min(ans, ans2);
if (ans3 != -1) ans = min(ans, ans3);
if (ans != a + b + c + 100)
cout << ans << endl;
else
cout << -1 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int MOD = 1000000007;
int main() {
long long a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] % 2 == a[1] % 2)
cout << a[1];
else
cout << a[2];
}
|
#include <bits/stdc++.h>
using namespace std;
long long min(long long a, long long b) {
if (a < b) return a;
return b;
}
int main() {
long long a, b, c, t;
cin >> a;
cin >> b;
cin >> c;
long long ans = 0;
if (a > b) {
t = a;
a = b;
b = t;
}
if (a > c) {
t = a;
a = c;
c = t;
}
if (b > c) {
t = b;
b = c;
c = t;
}
ans = c;
if ((b - a) % 2 == 0) ans = b;
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
const int maxn = 1000007;
const long long mod = 1e9 + 7;
int main() {
long long clr[4];
long long ans = -1;
for (int i = 0; i < 3; i++) {
std::cin >> clr[i];
ans += clr[i];
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i == j || (clr[i] + clr[j] & 1)) continue;
ans = std::min(ans, std::max(clr[i], clr[j]));
}
}
std::cout << ans << "\n";
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1029384756;
const double PI = acos(-1);
const double EPS = 0.0000000304;
long long A, B, C;
int main() {
scanf("%I64d%I64d%I64d", &A, &B, &C);
if ((A % 2) == (B % 2) && (B % 2) == (C % 2)) {
printf("%I64d", A + B + C - max(A, max(B, C)) - min(A, min(B, C)));
} else if (A % 2 == B % 2) {
printf("%I64d", max(A, B));
} else if (A % 2 == C % 2) {
printf("%I64d", max(A, C));
} else {
printf("%I64d", max(B, C));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
os << "{" << p.first << "," << p.second << "}";
return os;
}
const long long N = 3e5 + 5;
const long long oo = 1e9 + 7;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long a[3];
for (long long i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if ((a[1] - a[0]) % 2 == 0) {
cout << a[1] << "\n";
} else {
cout << a[2] << "\n";
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.