Cosmic-ray decreases and the occurrence of solar flares