1. Make a list of all existing Bitcoin addresses that have a balance (there's a topic on this where you can easily download the list).
2. You now have 2 lists: "funded" and "tocheck".
3. Make sure each list only has unique addresses.
4. Use "sort" and "uniq" (standard Linux commands) to find duplicates. Something like `cat funded tocheck | sort | uniq -c | sort -nr | head` will tell you if any address occurs on both lists.
5. If there is a match, find it's balance. If there are many matches, adjust the commands a bit.
The benefit of using the tools mentioned in step 4 is that they already exist, and are highly efficient in handling large amounts of data. It may require a lot of RAM, but if needed you can get that on the cloud for a short period.