Solve div1 medium.
Merge pull request #11 from matscube/SRM638

Solve div1 medium.