The U.S. dollar gained on Wednesday due to month-end buying and technical factors after recent declines that pushed it to its weakest in more than a