Well on the optical side you can do 40km(by spec of the manufacturer) of fiber, if you have the right SFP. and Singlemode fiber.
But most UHD SFP's only go up to 5 km.. Due to there very recent release.. There will be more modules in 1 or 2 years that will do 20/40km with 12G-SDI.
3G-SDI sfp's will be easier to get by in long range models.
On the HDMI side. Maximum 1 - 3 meters.. If you have HDMI 2.0A cable (for 4K )
You could do more and i even see cables up to 20 meters on hdmi.. But i don't recommend it as most of the video problems with HDMI come from too long cables.