Select id,name,(select id from contacts)(select id from Opportunity) from Account
List<Account> accounts = [SELECT Id, Name, (SELECT id FROM Contacts), (SELECT id FROM opportunities) FROM Account];
for (Account a : accounts) {
System.debug('Count of Opportunities is ' + a.Opportunities.size());
System.debug('Count of Contacts is ' + a.Contacts.size());
}