Let’s look at a very interesting USACO Gold problem Unbalance Photo. At first glimpse, it could be an easy and straightforward counting problem, but with up to 100000 cows, it will time out. How to solve it without TLE (Time Limit Exceeded)? We went through all details in Gold 2 Lesson 16.