U.S. consumer prices rose at a slower pace in July as gas prices fell and supply chains improved, but inflation held near its highest level in 40 years.