C++ Binary search solution
\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n        int mod = pow(10, 9) + 7, n = nums.size();\n        unsigned long long count = 0;
```\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n        int mod = pow(10, 9) + 7, n = nums.size();\n        unsigned long long count = 0;\n        vector<int> prefix(n + 1, 0);\n        for (int i = 0; i < nums.size(); i++)   prefix[i + 1] = prefix[i] + nums[i];\n        for (int i = 1; i <= n - 2; i++) {\n            int diff = prefix[n] - prefix[i];\n            int mid = diff / 2;\n            if (mid < prefix[i])    break;\n            mid += prefix[i];\n            //cout << i << ":" << prefix[i] << ":" << mid << endl;\n            vector<int> :: iterator it_up = upper_bound(prefix.begin() + i + 1, prefix.end() - 1, mid);\n            if (it_up == prefix.end()) break;\n            vector<int> :: iterator it_low = lower_bound(prefix.begin() + i + 1, \n                                                        prefix.end(), 2 * prefix[i]);\n            if (it_low == prefix.end()) break;\n            if (it_low == prefix.begin() + i)   ++it_low;\n            if (it_low < it_up) {\n                count += (it_up - it_low);\n                count %= mod;\n            }\n        }\n        \n        return count;\n    }\n};\n```
[]