My answer for ISUCON4 qualifier