Output in CHEFINV (Chef and Swaps) problem

I’ve just solved subj problem, but there is an interesting thing in the one: problem gets AC only with using “cout” (in c++) but “printf” neither with “%I64d” nor with “%lld” does not.


forn(i, 1, q) {                      
	//	printf("%lld\n", ans + q_res[i].ans);
		cout << ans + q_res[i].ans << "\n";
	}   

Both ans and q_res[i].ans are long long.

So this output code will work correctly, but the commented version won’t. What’s wrong?

//