The Pakistani military says its troops have killed nearly 40 militants in two separate attacks Sunday in the northwest region of the country .