Official figures show the UK economy contracted by 0.5% in July, more than economists predicted.