When you remove something, all following indexes decrease by 1. Incrementing your loop counter will skip the next element. They are the ones you are missing.
You need to do something like this:
Portfolio.total.get(k).remove(c); // you already have this line
c--;
Also, for the sake of readability I would prefer to use an Iterator
and it's remove()
method. This way you don't have to worry about indexes.