The input file format is correct (I verified it using a bunch of asserts). All numbers are positive integers between 1 and 50. I don't really know what your phrase "value may be long" wanted to say... but all intermediate results will surely fit into a int.
The only change I had to make in my (previously correct and AC, currently WA) code to get it accepted is to change
"output whether 23 can be reached"
to
"output whether 23 or -23 can be reached".
Oh boy, I wonder why they bothered to "rejudge" the problem
![:(](./images/smilies/icon_frown.gif)