Some code i wrote for algorithm competition.