"And there was a famine in the land" (Genesis 26:1). It is written, "The LORD knows the days of the blameless" (Psalms 37:18) — this is Isaac; "and their inheritance shall be forever" — "Dwell in this land" (Genesis 26:3). "They shall not be put to shame in the time of evil" (Psalms 37:19) — in the evil of Abimelech; "and in the days of famine they shall be satisfied" — "And there was a famine in the land." "The LORD will not let the soul of the righteous go hungry" (Proverbs 10:3) — this is Isaac, "Dwell in this land." "But He thrusts away the craving of the wicked" — this is Abimelech. Ten kinds of famine, and so on (as written in remez 46).
Isaac the Blameless and the Famine That Did Not Shame Him
Yalkut Shimoni on Torah 111:6
(בראשית כו א-ג) וַיְהִי רָעָב בָּאָרֶץ, כְּתִיב (תהלים לז, יח יט) "יוֹדֵעַ ה' יְמֵי תְמִימִים" [זֶה יִצְחָק] "וְנַחֲלָתָם לְעוֹלָם תִּהְיֶה" גּוּר בָּאָרֶץ הַזֹּאת. (תהלים שם) "לֹא יֵבוֹשׁוּ בְּעֵת רָעָה", בְּרָעָתוֹ שֶׁל אֲבִימֶלֶךְ "וּבִימֵי רְעָבוֹן יִשְׂבָּעוּ" וַיְהִי רָעָב בָּאָרֶץ. לֹא יַרְעִיב ה' נֶפֶשׁ צַדִּיק זֶה יִצְחָק גּוּר בָּאָרֶץ הַזֹּאת. "וְהֲוַּת רְשָׁעִים יֶהְדֹּף" זֶה אֲבִימֶלֶךְ. עֲשָׂרָה מִינֵי רְעָבוֹן וְכוּ' (כִּדְכָתוּב בְּרֶמֶז (מ"ו)).