Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
    string S;
    cin >> S;

    int N = S.size() + 1;
    int lparNum = 0;
    int rparNum = 0;
    long long ans = 0;

    const regex lre("^<+");
    const regex rre("^>+");
    smatch m;

    for(size_t i = 0; i < S.size(); i++){
        if(regex_search(S.substr(0, i), m, lre)){
            for(size_t j = 0; j < m.size(); j++){
                lparNum = m.str(j).size();
            }
        }
        if(regex_search(S.substr(i), m, rre)){
            for(size_t j = 0; j < m.size(); j++){
                rparNum = m.str(j).size();
            }
        }
//        cout << "i = " << i << " : " << max(lparNum, rparNum) << endl;
        ans += max(lparNum, rparNum);
    }
    cout << ans << endl;
    /*

    long long ans = 0;
    for(size_t i = 0; i < S.size(); i++){
        if(S[i] == '<') lparNum = count(S.begin(), S.begin() + i, '<');
        else if(S[i] == '>') rparNum = count(S.begin() + i, S.end(), '>');
        cout << "(lparNum, rparNum) = " << lparNum << "," << rparNum << endl;
        ans += max(lparNum, rparNum);
    }
    cout << ans << endl;
    */
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:24: error: use of deleted function 'bool std::regex_search(const __cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&, __cxx11::match_results<typename __cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, regex_constants::match_flag_type) [with _Ch_traits = char_traits<char>; _Ch_alloc = allocator<char>; _Alloc = allocator<__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, __cxx11::basic_string<char> > > >; _Ch_type = char; _Rx_traits = __cxx11::regex_traits<char>; typename __cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>::const_iterator = __cxx11::basic_string<char>::const_iterator]'
   18 |         if(regex_search(S.substr(0, i), m, lre)){
      |            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
                 from a.cc:1:
/usr/include/c++/14/bits/regex.h:2540:5: note: declared here
 2540 |     regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&,
      |     ^~~~~~~~~~~~
a.cc:18:24: note: use '-fdiagnostics-all-candidates' to display considered candidates
   18 |         if(regex_search(S.substr(0, i), m, lre)){
      |            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:23:24: error: use of deleted function 'bool std::regex_search(const __cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&, __cxx11::match_results<typename __cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, regex_constants::match_flag_type) [with _Ch_traits = char_traits<char>; _Ch_alloc = allocator<char>; _Alloc = allocator<__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, __cxx11::basic_string<char> > > >; _Ch_type = char; _Rx_traits = __cxx11::regex_traits<char>; typename __cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>::const_iterator = __cxx11::basic_string<char>::const_iterator]'
   23 |         if(regex_search(S.substr(i), m, rre)){
      |            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2540:5: note: declared here
 2540 |     regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&,
      |     ^~~~~~~~~~~~
a.cc:23:24: note: use '-fdiagnostics-all-candidates' to display considered candidates
   23 |         if(regex_search(S.substr(i), m, rre)){
      |            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~