Japan’s imports and exports set records in July, though soaring energy costs and a weak yen helped extend a trade deficit for a third straight month