The Residency Matching algorithm pairs medical school graduates(residents) and residency slots  at teaching hospitals. Residents and hospitals submit their ordered preference list, and the stable pairing produced by matching residents with residency programs, i.e. a set of residents  has to  be assigned to a set of hospitals.