Language: C++

    #include "bits/stdc++.h"
            using namespace std;
             
            #define MAX 600012
             
            int n;
            char buf[MAX];
            string s;
            valarray<long long int> MOD1;
            valarray<long long int> MOD2;
            vector<valarray<long long int> > p2;
            vector<valarray<long long int> > vv;
            vector<int> ps;
            map<pair<long long int,long long int>, int> mp;
            long long int ppow(long long int i, long long int j, long long int MOD) {
            	long long int ret = 1;
            	while (j) {
            		if (j & 1LL)ret *= i;
            		if (ret >= MOD)ret %= MOD;
            		j >>= 1LL;
            	}
            	return ret;
            }
             
            valarray<long long int> calc(int dif) {
            	valarray<long long int> ret;
            	ret.resize(2, 0);
            	for (int j = 0; j < 2; j++) {
            		if (dif < 0) {
            			ret[j]=ppow(ppow(MOD1[j],MOD2[j]-2,MOD2[j]),-dif,MOD2[j]);
            		}
            		else {
            			ret[j] = ppow(MOD1[j],dif, MOD2[j]);
            		}
            	}
            	return ret;
            }
             
            int main() {
            	MOD1.resize(2);
            	MOD2.resize(2);
            	p2.push_back(valarray<long long int>());
            	p2.back().resize(2);
            	p2.back()[0] = p2.back()[1] = 1;
            	MOD2[1] = 1000000007;
            	MOD1[0] = 555522277;
            	MOD1[1] = 895612782;
            	MOD2[0] = 998244353;
            	p2[0] %= MOD2;
            	for (int i = 1; i < MAX; i++) p2.push_back((p2.back()*MOD1)%MOD2);
            	cin >> n;
            	scanf("%s", buf);
            	s = buf;
            	int pos = MAX/2;
            	valarray<long long int> hs;
            	hs.resize(2,0);
            	vv.push_back(hs);
            	ps.push_back(pos);
            	for (int i = 0; i < s.size(); i++) {
            		if (s[i] == '<') pos--;
            		else if (s[i] == '>') pos++;
            		else if (s[i] == '+') hs += p2[pos];
            		else if (s[i] == '-') hs += MOD2-p2[pos];
            		hs %= MOD2;
            		if(hs[0]<0LL||hs[1]<0LL||p2[0]<0LL||p2[1]<0LL)return 1;
            		vv.push_back(hs);
            		ps.push_back(pos);
            	}
            	long long int way = 0;
            	for (int i = vv.size() - 1; i >= 0; i--) {
            		valarray<long long int> want = (vv[i] + ((vv.back()*calc(-MAX/2+ps[i]))%MOD2))%MOD2;
            		way += mp[make_pair(want[0], want[1])];
            		mp[make_pair(vv[i][0],vv[i][1])]++;
            	}
            	printf("%lld\n", way);
            	return 0;
            }

Compiler output:
a.cc: In function 'int main()':
a.cc:65:59: error: could not convert 'std::operator||<__detail::_BinClos<__logical_or, _Constant, _Expr, bool, __detail::_BinClos<__less, _ValArray, _Constant, long long int, long long int> >, __detail::_BinClos<__less, _ValArray, _Constant, long long int, long long int> >(std::operator||<__detail::_BinClos<__less, _ValArray, _Constant, long long int, long long int> >(((hs.std::valarray<long long int>::operator[](0) < 0) || (hs.std::valarray<long long int>::operator[](1) < 0)), std::operator< <long long int>((*(const std::valarray<long long int>*)(& p2.std::vector<std::valarray<long long int> >::operator[](0))), 0)), std::operator< <long long int>((*(const std::valarray<long long int>*)(& p2.std::vector<std::valarray<long long int> >::operator[](1))), 0))' from 'std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Expr, std::_Expr, std::__detail::_BinClos<std::__logical_or, std::_Constant, std::_Expr, bool, std::__detail::_BinClos<std::__less, std::_ValArray, std::_Constant, long long int, long long int> >, std::__detail::_BinClos<std::__less, std::_ValArray, std::_Constant, long long int, long long int> >, bool>' to 'bool'
   65 |                         if(hs[0]<0LL||hs[1]<0LL||p2[0]<0LL||p2[1]<0LL)return 1;