  We investigate the molecular evolution and D/H abundance ratios that develop
as star formation proceeds from a dense-cloud core to a protostellar core, by
solving a gas-grain reaction network applied to a 1-D radiative hydrodynamic
model with infalling fluid parcels. Spatial distributions of gas and ice-mantle
species are calculated at the first-core stage, and at times after the birth of
a protostar. Gas-phase methanol and methane are more abundant than CO at radii
$r\lesssim 100$ AU in the first-core stage, but gradually decrease with time,
while abundances of larger organic species increase. The warm-up phase, when
complex organic molecules are efficiently formed, is longer-lived for those
fluid parcels in-falling at later stages. The formation of unsaturated carbon
chains (warm carbon-chain chemistry) is also more effective in later stages;
C$^+$, which reacts with CH$_4$ to form carbon chains, increases in abundance
as the envelope density decreases. The large organic molecules and carbon
chains are strongly deuterated, mainly due to high D/H ratios in the parent
molecules, determined in the cold phase. We also extend our model to simulate
simply the chemistry in circumstellar disks, by suspending the 1-D infall of a
fluid parcel at constant disk radii. The species CH$_3$OCH$_3$ and HCOOCH$_3$
increase in abundance in $10^4-10^5$ yr at the fixed warm temperature; both
also have high D/H ratios.
