Pakistan’s inflation accelerated to the highest in two years as the war in the Middle East pushed up energy import costs.