Hunger states switch a flip-flop memory circuit via a synaptic AMPK-dependent positive feedback loop.