Hi, Cathy. There is no solvent that will reliabably remove the foam and paint without possibly harming the finish that is on the floors. Aside from that, you probably have nail holes from tack strips for the carpet. The best thing to do is to sand and refinish or have the floors sanded and refinished. This might seem expensive but new carpet would be also. Henry in MI