OUCH!
long long ans = LONG_MAX, instead of LLONG_MAX, and that was my submission to problem C GONE.
ICPC NA North Central and South Division