I'm not quite sure where the problem is, but here is the story. First, I tried to submit solution which worked well on my machine (64bit OS), but test 1 was constantly failed on timus server. I've tried to change (almost) everything in my code without success. Then I started to google solutions. Surprisingly, they didn't worked either (e.g.
http://helloacm.com/coding-exercise-timus-1001-reverse-root-c-solution-online-judge/ is provided as a working solution, but it also fails on test 1). I've started to think that something is broken on the timus server or I'm choosing wrong compiler version or hell knows what else. Then I've found another solution which was... accepted! Started to comparing it with mine line by line and found following:
whatever I use in scanf (llu, lld) - it works fine on my machine, but on remote server it fails. When you replace scanf by cin - it works both locally and remotely. So in short - do not use scanf for this task, use cin.
It will be very interesting to know why this happens, maybe someone could explain?