Tight bounds for the probability of overfitting