Thank you for sharing @juwu. Flattening is not the best way to verify a contract. If you deployed with Hardhat, did you try the hardhat-etherscan plugin? Note that despite the name it supports Polygonscan as well.
People having issues with verification should consult the main resource guide: