Are you sure that C++11 is turned on? %lld is correnct fomat specifier to use in this case. Are you sure that you pass arguments correctly? Remember, scanf() expects pointers to values.
I have been using std::cin which always causes a time limit exceeded.Turn off c-streams synchronisation: std::cin.sync_with_stdio(false);
Place this at the beginning of main();
Comparison of different input methods: http://puu.sh/eUY2H/511ac8f0d4.png
C and C++ standard streams are different. Each has own buffer and ways to access it.
To avoid situaltion when input already read from cin pops up in stdin, or when scanf discards chunks of input lying in cin buffer, those streams are synchronised. That means that every operation on cin includes synchronising own buffer with stdin, performing operation and synchronising stdin buffer with cin buffer. This incurs heavy cost on cin operations. Call to std::cin.sync_with_stdio(false); turns off that synchronisations. It is usually significantly speeds up cin operations (at least for libstdc++). After that you cannot mix C and C++ standard streams. You should stick with one.