Here is my code: Dynamic Input Groups

Group 1

Group 2

Balanced:
 
Chemical Calculation