From Chinese 蟾宮 ("Toad Palace") + 折 ("break off") + 桂 ("osmanthus"), "to break off osmanthus [blossoms] in the Toad Palace". The phrase references several Chinese legends: one that credited the phases of the moon to a great osmanthus tree (桂) growing and shedding its leaves and blossoms each month; another granting the immortal Chang'e an enormous mansion on the moon (月宫), whose grounds included the tree; another (older than the Chang'e stories) seeing a pareidolic toad in the shadows of the moon and associating the toad with good luck and wealth (金蟾). Branches of sweet-smelling blossoms from the tree were thought to (rarely) fall to Earth and grant good luck to whosoever found them. The association with the tests had to do with the holding of the examinations around the time of the blossoming of the osmanthus and the Mid-Autumn Festival honoring its connections to the moon and Chang'e.
蟾宮折桂 (traditional, Pinyin 蟾宫折桂), simplified