The present invention provides a heterocycle derivative having a superior amyloid &bgr; production inhibitory activity and/or a superior γ-secretase modulation activity, and use thereof. A compound represented by the formula (I): wherein each symbol is as defined in the present specification, or a salt thereof.