Comments

I wonder what the full input of testcase 138 in Div1B is. This testcase specifically kills random_device users, isn't it......?

Sample code with random_device: http://codeforces.me/contest/1039/submission/42539354

When I use mt19937_64, it works well.

Only substituting mt19937_64 for random_device: http://codeforces.me/contest/1039/submission/42539386

Or does random_device have any bad feature I don't know?