std::sync_with_stdio(false);にすると結構速いよ

http://d.hatena.ne.jp/s-yata/20100726/1280138663
http://tatanaideyo.hatenablog.com/entry/2014/10/24/214714