Residents of the German city of Hamburg have voted against hosting the 2024 Olympic and Paralympic Games.