If a friend tells you how he studied for two weeks solid and is proud he got a 91% on a mid-term exam, this is not the time to bring up how you forgot to study and still got a 97%. If he directly asks, tell him that you also got an “A” and are relieved that mid-terms are done and over and/or that you should go celebrate how both of you did so well. You can be still honest without bringing up specific details that might hurt your friend’s feelings. If your friend directly asks how much you studied, you can say something like, “I should have studied more,” or “Who knows? I don’t keep track of time when I study.”
Your friends will resent you if you don’t help them to feel good about themselves, or at least allow them to continue feeling victorious. Congratulate your friend. Tell your friend that you knew s/he could do it. Tell your friend that s/he deserves the win. Share your own glories the next day, after lunch, or after the subject has been changed a few times.