Sefer Chasidim Siman 609
Can copy this into an AI, or connect the whole library to your assistant. For deeper learning, you can directly use the original seforim, sites, and apps.
אמרו צדיק נוטל חלקו וחלק חבירו רשע בעדן ונוטל רשע חלקו וחלק חבירו צדיק בגיהנם ויחלץ צדיק מצרה ויבא רשע תחתיו:
Medieval Jewish mysticism, translated by Sholom Alchanan Singer. Northbrook, Ill. Whitehall Co., 1971
They said: a tsadik takes his portion in Eden and the portion of a sinner, while as for Gehinom - a sinner takes his portion and that of a tsadik. A tsadik gets saved from an adversity while a sinners encounters it instead of him.