The U.S. president is whoever gets a majority of electoral votes. Electoral votes are not quite proportional to population. Each state has 2 senators regardless of population. Each state has House representatives proportional to population. These representatives are elected by districts into which each state is divided.
Justices stay until they retire or die.
Congress has the power to change the number of justices, but this hasn't happened for about 100 years. The Median Voter Theorem, taken strictly, does not predict that the preference of the median U.S. voter will prevail under these circumstances. The U.S. president will cater to the median electoral vote. Senators will cater to the median voter in their state . Representatives will cater to the median voter in their district .