Watermelon, and why the answer is almost always yes
TLEvision / 6 Aug 2026
Problem 4A gives you a watermelon of weight w and asks whether two people can split it so that both parts are even and neither is zero.
The instinct is to loop over every split. You don't need to.
The shape of the answer
Write the split as w=a+b with a,b>0 and both even. If both parts are even then their sum is even, so w must be even — an odd w is immediately no.
Now suppose w is even and w>2. Take a=2. Then b=w−2, which is even because it's an even number minus an even number, and positive because w>2. So a valid split always exists.
That leaves w=2: the only split is 1+1, which is odd on both sides. No.
So the whole problem is
#include <iostream>
int main() {
long long w;
std::cin >> w;
std::cout << (w > 2 && w % 2 == 0 ? "YES" : "NO") << '\n';
}
O(1) time, O(1) memory, and no loop anywhere.
The habit worth taking from it
The loop version passes too — w≤100 in the original constraints. But the question "for which inputs is the answer no?" is faster to answer than "how do I search for a split?", and it generalises. When a problem asks does there exist, try characterising the failures first. There are usually very few.
Here there are exactly two: odd numbers, and 2.