Language: C++

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

const pair<LL, LL> HMOD = MP(998244353, 1004535809), HRAD = MP(243, 19683), HIRAD = MP(607984215, 858522653);
map<pair<LL, LL>, int> S;
int n;
char ch[250005];

int main()
{
	cout << power(243, MOD - 2);
	scanf("%d%s", &n, &ch);
	LL cur = MP(1, 1), cnt = MP(0, 0);
	rep(i, n) {
		if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
		if(ch[i] == '-') cnt.first = (cnt.first - cur.first + HMOD.first) % HMOD.first;
		if(ch[i] == '<') cur.first = cur.first * HIRAD.first % HMOD.first;
		if(ch[i] == '>') cur.first = cur.first * HRAD.first % HMOD.first;
		if(ch[i] == '+') cnt.second = (cnt.second + cur.second) % HMOD.second;
		if(ch[i] == '-') cnt.second = (cnt.second - cur.second + HMOD.second) % HMOD.second;
		if(ch[i] == '<') cur.second = cur.second * HIRAD.second % HMOD.second;
		if(ch[i] == '>') cur.second = cur.second * HRAD.second % HMOD.second;
		S[cnt] ++;
	}
	pair<LL, LL> ss = cnt;
	ans = S[ss];
	cur = MP(1, 1); cnt = MP(0, 0);
	rep(i, n) {
		if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
		if(ch[i] == '-') cnt.first = (cnt.first - cur.first + HMOD.first) % HMOD.first;
		if(ch[i] == '<') cur.first = cur.first * HIRAD.first % HMOD.first;
		if(ch[i] == '>') cur.first = cur.first * HRAD.first % HMOD.first;
		if(ch[i] == '+') cnt.second = (cnt.second + cur.second) % HMOD.second;
		if(ch[i] == '-') cnt.second = (cnt.second - cur.second + HMOD.second) % HMOD.second;
		if(ch[i] == '<') cur.second = cur.second * HIRAD.second % HMOD.second;
		if(ch[i] == '>') cur.second = cur.second * HRAD.second % HMOD.second;
		S[cnt] --;
		ans += S[MP((cnt.first + cur.first * ss.first) % HMOD.first, (cnt.second + cur.second * ss.second) % HMOD.second)];
	}
	printf("%lld\n", ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:28: error: 'MOD' was not declared in this scope; did you mean 'HMOD'?
   59 |         cout << power(243, MOD - 2);
      |                            ^~~
      |                            HMOD
a.cc:59:17: error: 'power' was not declared in this scope
   59 |         cout << power(243, MOD - 2);
      |                 ^~~~~
a.cc:61:20: error: cannot convert 'std::pair<int, int>' to 'LL' {aka 'long long int'} in initialization
   61 |         LL cur = MP(1, 1), cnt = MP(0, 0);
      |                    ^
      |                    |
      |                    std::pair<int, int>
a.cc:61:36: error: cannot convert 'std::pair<int, int>' to 'LL' {aka 'long long int'} in initialization
   61 |         LL cur = MP(1, 1), cnt = MP(0, 0);
      |                                    ^
      |                                    |
      |                                    std::pair<int, int>
a.cc:63:38: error: request for member 'first' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   63 |                 if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
      |                                      ^~~~~
a.cc:63:51: error: request for member 'first' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   63 |                 if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
      |                                                   ^~~~~
a.cc:63:63: error: request for member 'first' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   63 |                 if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
      |                                                               ^~~~~
a.cc:64:38: error: request for member 'first' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   64 |                 if(ch[i] == '-') cnt.first = (cnt.first - cur.first + HMOD.first) % HMOD.first;
      |                                      ^~~~~
a.cc:64:51: error: request for member 'first' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   64 |                 if(ch[i] == '-') cnt.first = (cnt.first - cur.first + HMOD.first) % HMOD.first;
      |                                                   ^~~~~
a.cc:64:63: error: request for member 'first' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   64 |                 if(ch[i] == '-') cnt.first = (cnt.first - cur.first + HMOD.first) % HMOD.first;
      |                                                               ^~~~~
a.cc:65:38: error: request for member 'first' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   65 |                 if(ch[i] == '<') cur.first = cur.first * HIRAD.first % HMOD.first;
      |                                      ^~~~~
a.cc:65:50: error: request for member 'first' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   65 |                 if(ch[i] == '<') cur.first = cur.first * HIRAD.first % HMOD.first;
      |                                                  ^~~~~
a.cc:66:38: error: request for member 'first' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   66 |                 if(ch[i] == '>') cur.first = cur.first * HRAD.first % HMOD.first;
      |                                      ^~~~~
a.cc:66:50: error: request for member 'first' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   66 |                 if(ch[i] == '>') cur.first = cur.first * HRAD.first % HMOD.first;
      |                                                  ^~~~~
a.cc:67:38: error: request for member 'second' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   67 |                 if(ch[i] == '+') cnt.second = (cnt.second + cur.second) % HMOD.second;
      |                                      ^~~~~~
a.cc:67:52: error: request for member 'second' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   67 |                 if(ch[i] == '+') cnt.second = (cnt.second + cur.second) % HMOD.second;
      |                                                    ^~~~~~
a.cc:67:65: error: request for member 'second' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   67 |                 if(ch[i] == '+') cnt.second = (cnt.second + cur.second) % HMOD.second;
      |                                                                 ^~~~~~
a.cc:68:38: error: request for member 'second' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   68 |                 if(ch[i] == '-') cnt.second = (cnt.second - cur.second + HMOD.second) % HMOD.second;
      |                                      ^~~~~~
a.cc:68:52: error: request for member 'second' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   68 |                 if(ch[i] == '-') cnt.second = (cnt.second - cur.second + HMOD.second) % HMOD.second;
      |                                                    ^~~~~~
a.cc:68:65: error: request for member 'second' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   68 |                 if(ch[i] == '-') cnt.second = (cnt.second - cur.second + HMOD.second) % HMOD.second;
      |                                                                 ^~~~~~
a.cc:69:38: error: request for member 'second' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   69 |                 if(ch[i] == '<') cur.second = cur.second * HIRAD.second % HMOD.second;
      |                                      ^~~~~~
a.cc:69:51: error: request for member 'second' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   69 |                 if(ch[i] == '<') cur.second = cur.second * HIRAD.second % HMOD.second;
      |                                                   ^~~~~~
a.cc:70:38: error: request for member 'second' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   70 |                 if(ch[i] == '>') cur.second = cur.second * HRAD.second % HMOD.second;
      |                                      ^~~~~~
a.cc:70:51: error: request for member 'second' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   70 |                 if(ch[i] == '>') cur.second = cur.second * HRAD.second % HMOD.second;
      |                                                   ^~~~~~
a.cc:71:18: error: no match for 'operator[]' (operand types are 'std::map<std::pair<long long int, long long int>, int>' and 'LL' {aka 'long long int'})
   71 |                 S[cnt] ++;
      |                  ^
In file included from /usr/include/c++/14/map:63,
                 from a.cc:38:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<long long int, long long int>; _Tp = int; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >; mapped_type = int; key_type = std::pair<long long int, long long int>]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'LL' {aka 'long long int'} to 'const std::map<std::pair<long long int, long long int>, int>::key_type&' {aka 'const std::pair<long long int, long long int>&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<long long int, long long int>; _Tp = int; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >; mapped_type = int; key_type = std::pair<long long int, long long int>]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'LL' {aka 'long long int'} to 'std::map<std::pair<long long int, long long int>, int>::key_type&&' {aka 'std::pair<long long int, long long int>&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
a.cc:73:27: error: conversion from 'LL' {aka 'long long int'} to non-scalar type 'std::pair<long long int, long long int>' requested
   73 |         pair<LL, LL> ss = cnt;
      |                           ^~~
a.cc:74:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   74 |         ans = S[ss];
      |         ^~~
      |         abs
a.cc:75:17: error: cannot convert 'std::pair<int, int>' to 'LL' {aka 'long long int'} in assignment
   75 |         cur = MP(1, 1); cnt = MP(0, 0);
      |                 ^
      |                 |
      |                 std::pair<int, int>
a.cc:75:33: error: cannot convert 'std::pair<int, int>' to 'LL' {aka 'long long int'} in assignment
   75 |         cur = MP(1, 1); cnt = MP(0, 0);
      |                                 ^
      |                                 |
      |                                 std::pair<int, int>
a.cc:77:38: error: request for member 'first' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   77 |                 if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
      |                                      ^~~~~
a.cc:77:51: error: request for member 'first' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   77 |                 if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
      |                                                   ^~~~~
a.cc:77:63: error: request for member 'first' in 'cur', which is of non-class type 'LL' {aka 'long long int'}
   77 |                 if(ch[i] == '+') cnt.first = (cnt.first + cur.first) % HMOD.first;
      |                                                               ^~~~~
a.cc:78:38: error: request for member 'first' in 'cnt', which is of non-class type 'LL' {aka 'long long int'}
   78 |                 if(ch[i] == '-') cnt.first = (cnt.first - cur.first + HMOD.first) % HMOD.first