Not sure what happened when you submitted.
I tried submitting the same code, with fast I/O here and it passes.
[EDIT]: Well well well, you have used "%d" to scan a long long datatype. Here is the accepted solution with scanf() using the proper type specifier, that is "%lld".