End Google Ads 201810 - BS.net 01 --> Hi

I am trying to understand how to solve this one:
There is given a table with clients and products
Like that

client_code product_code1
client_code product_code2
client_code product_code3

Each row has client code and product code.
Table is sorted according to clients.
Program should count how many times given client bought products.
Unfortunately it should be done with pessimistic complexity O(log n)
where n is amount of elements in the table.

Any ideas?