Teraelectronvolt pulsed emission from the Crab pulsar detected by MAGIC