```
class FourSum {
public:
int fourSumCount(vector<int>& A, vector<int>& B, vector<int>& C, vector<int>& D) {
unordered_map<int, int> ab, cd;
for (int i : A) for (int j : B) ab[i+j]++;
for (int i : C) for (int j : D) cd[i+j]++;
int res = 0;
for (auto i : ab)
res += i.second * cd[-i.first];
return res;
}
};
```