Insane memory usage which I cannot explain - Codeforces
The memory problem was indeed caused by knapsack |= knapsack << count[v];, as it creates a temprorary bitset on the stack. I was able to fix that here: link I didn't really get into the problem, but I think that