When you write a large number like 1000000000, C++ treats it as an int by default. If you multiply two such numbers, overflow happens before the result reaches your long long variable.
Add LL after a number to make it long long: 1000000000LL. Now the multiplication uses 64-bit arithmetic and does not overflow. Example: long long result = 1000000000 * 1000000000; overflows.
But long long result = 1000000000LL * 1000000000LL; works correctly.