I was wondering now for sometime why my graph solutions usually take much more memory than fairly similar solutions in java. The thing is, I have avoided arrays of arraylist since arrays cant be assigned generics (if you use (ArrayList) array, some sites dont even accept your solution, but I have only know found out that you can just leave it without assigning this and it works just fine), but I have now finally tried using this, look at the result of two almost identical programs, only one has list of lists while the other has array of lists: (list of lists)-https://codeforces.net/contest/1324/submission/78422102 (array of lists)-https://codeforces.net/contest/1324/submission/78422518. Anyone knows why is this the case?