Interaction of cosmic rays with molecular clouds