TopCoder SRM 594, task 500
change flow algorithm - remove constant dependancy, make nicer with c++11