Republican candidates for president trade sharp blows over foreign policy and the future of the Supreme Court in an often unruly and chaotic debate.