Input-matching is a key mechanism by which animals optimally distribute themselves across habitats to maximize net gains based on the changing input values of food supply rate and competition. To examine the neural systems that underlie this rule in humans, we created a continuous-input foraging task where subjects had to decide to stay or switch between two habitats presented on the left and right of the screen. The subject's decision to stay or switch was based on changing input values of reward-token supply rate and competition density. High density of competition or low-reward token rate was associated with decreased chance of winning. Therefore, subjects attempted to maximize their gains by switching to habitats that possessed low competition density and higher token rate. When it was increasingly disadvantageous to be in a habitat, we observed increased activity in brain regions that underlie preparatory motor actions, including the dorsal anterior cingulate cortex and the supplementary motor area, as well as the insula, which we speculate may be involved in the conscious urge to switch habitats. Conversely, being in an advantageous habitat is associated with activity in the reward systems, namely the striatum and medial prefrontal cortex. Moreover, amygdala and dorsal putamen activity steered interindividual preferences in competition avoidance and pursuing reward. Our results suggest that input-matching decisions are made as a net function of activity in a distributed set of neural systems. Furthermore, we speculate that switching behaviors are related to individual differences in competition avoidance and reward drive.