write an algorithm for which
the input is n pairs on whole positive numbers:

and number k.

the output is the k smallest in a list
where xi appears wi times

for example: n=4
gives us
the list
and the out put is 5 (becuase the 8'th smallest cell is 8)

the solution makes three arrays:
one for the x coordinates X
one for the w coordinates W

and the third is XW=[(x1,w1),..,(xn,wn)]

cant understand what are they doing in this code to get the k'th smallest?