Sodium hydrogen carbonate (baking soda) is used as an antacid because it neutralises excess acid present in the stomach. It reacts with dilute hydrochloric acid to produce carbon dioxide gas, which is used in fire extinguishers.
Hence, substance X is sodium hydrogen carbonate (baking soda) and Y is carbon dioxide gas.
The reaction between sodium hydrogen carbonate and hydrochloric acid gives sodium chloride, carbon dioxide and water.
HCl(aq) + NaHCO3(s) → NaCl(s) + H2O(l) + CO2(g)