The drug which is protected by patent is a branded drug (Patent Medicine) and the drug which is a copy of branded drug and is equivalent in terms of safety, efficacy, dosage and use is called a generic drug. Generic drugs will cost less.
The active ingredients are the same. The difference are in the inactive ingredients.
However, this only applies to compounds. If you are talking about biologics... it's not as simple. For these, the "generic" are called biosimilars and there are vast differences between them and the brand name. Mostly becuase the product is made from live cells.
The drug which is protected by patent is a branded drug (Patent Medicine) and the drug which is a copy of branded drug and is equivalent in terms of safety, efficacy, dosage and use is called a generic drug. Generic drugs will cost less.