Even though your variable x is large enough to hold the answer 40000000000, the constants 200000 are treated as integers, such that the multiplication is first fitted in an integer that is too small.
The solution is to use the 'LL' suffix on the constants, so that the compiler knows to treat them as long longs from the start:
long long x = 200000LL * 200000LL;
The number 1345294336 can be explained by ANDing 40000000000 with 0xFFFFFFFF (which is the maximum size of an unsigned long)