Harry was almost glad that the exams weren't far away. All the studying he had to do kept his mind off his misery. He, Ron, and Hermione kept to themselves, working late into the night, trying to remember the ingredients in complicated potions, ....
-Harry potter and the sorcerer's stone (J.K Rowling)
"keep to themselves" mean 'to spend time alone, not talking to other people very much'. But I'm not sure if it means
(A) Harry, Ron, and Hermione each spent time alone. So even the three of them barely met each other?
(B) Harry, Ron, and Hermione spent time with each other only, not talking to other people?
If it means (A), and if I want to make a sentence which means (B), using 'keep to themselves', how should the sentence be?