Renormalization-group study of competition between density waves and pairing in quasi-one-dimensional electron systems