Language: C++

#include<bits/stdc++.h>

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int N;
string S;
using H = unsigned long long;
namespace RollHash {
	constexpr int RANGE = 2123456;
	constexpr int MID = 512345;
	constexpr int num = 2;
	struct pH {
		H v[num];
		H& operator[](int i) {
			return v[i];
		}
	};
	constexpr H h[num] = { 1e9 + 7,1e9 + 9 };
	pH RS[RANGE];
	map<pair<H, H>, LL> cnt;
	void init() {
		cnt.clear();
		for (int i : range(num)) {
			RS[0][i] = 1;
		}
		for (int i : range(1,RANGE)) {
			for (int j : range(num)) {
				RS[i][j] = RS[i - 1][j] * h[j];
			}
		}
	}
	inline pH add(pH has, int pos) {
		for (int i : range(num)) {
			has[i] += RS[MID + pos][i];
		}
		return has;
	}
	inline pH sub(pH has, int pos) {
		for (int i : range(num)) {
			has[i] -= RS[MID + pos][i];
		}
		return has;
	}
	inline pH sub(pH l, pH r) {
		for (int i : range(num)) {
			l[i] -= r[i];
		}
		return l;
	}

	constexpr int A = 512345;
	inline pH moveCenter(pH has, int nowCenter) {
		const int movement = A - nowCenter;
		for (int i : range(num)) {
			has[i] *= RS[movement][i];
		}
		return has;
	}
	inline pH shift(pH has, int sft) {
		const int movement = A +sft;
		for (int i : range(num)) {
			has[i] *= RS[movement][i];
		}
		return has;
	}
	inline void ins(pH has,int c) {
		cnt[{has[0], has[1]}] += c;
	}
	inline LL get(pH has) {
		return cnt[{has[0], has[1]}];
	}
}
int main() {
	using namespace RollHash;
	while (cin >> N >> S) {
		init();
		LL ret = 0;

		vector<pH> suf(N + 1);
		vector<int> sft(N + 1);
		sft[0] = 0;
		for (int i : range(N)) {
			sft[i + 1] = sft[i];
			if (S[i] == '>')sft[i + 1]++;
			if (S[i] == '<')sft[i + 1]--;
		}
		pH now{ 0,0 };
		int center = 0;
		suf[N] = shift(moveCenter(now, center), sft[N]);
		ins(suf[N], 1);
		for (int ri : range(N)) {
			const int i = N - 1 - ri;
			if (S[i] == '+')now = add(now, center);
			if (S[i] == '-')now = sub(now, center);
			if (S[i] == '>')center--;
			if (S[i] == '<')center++;
			suf[i]=shift(moveCenter(now, center),sft[i]);
			ins(suf[i], 1);
		}
		now = moveCenter(now, center);
		for (int i : range(N)) {
			ins(suf[i], -1);
			auto latte = suf[i];
			auto malta = shift(now, sft[i]);
			auto ei = sub(latte, malta);
			LL beet = get(ei);
			ret += beet;
		}

		cout << ret << endl;
	}
	return 0;
}


Compiler output:
a.cc:36:36: error: narrowing conversion of '1.000000007e+9' from 'double' to 'H' {aka 'long long unsigned int'} [-Wnarrowing]
   36 |         constexpr H h[num] = { 1e9 + 7,1e9 + 9 };
      |                                ~~~~^~~
a.cc:36:44: error: narrowing conversion of '1.000000009e+9' from 'double' to 'H' {aka 'long long unsigned int'} [-Wnarrowing]
   36 |         constexpr H h[num] = { 1e9 + 7,1e9 + 9 };
      |                                        ~~~~^~~