constraint mem at the end in main