Language: C++

#include <iostream>
#include <string.h>

using namespace std;

void set_zeroes(string s, int *arr) {
    if (s[0] == '<') arr[0] = 0;
    if (s[s.size() - 1] == '>') arr[s.size()] = 0;
    for (int i = 0; i < s.size(); ++i) if (s[i] == '>' && s[i + 1] == '<') arr[i + 1] = 0;
}

void fill_right(int *arr, string s) {
    int i = 0;
    while (i < s.size()) {
        if (arr[i] == 0) {
            while (s[i] == '<') {
                arr[i + 1] = arr[i] + 1;
                i++;
            }
        }
        i++;
    }
}

void fill_left(int *arr, string s) {
    int i = s.size();
    while (i > 0) {
        if (arr[i] == 0) {
            while (s[i - 1] == '>') {
                if (arr[i] + 1 > arr[i - 1]) arr[i - 1] = arr[i] + 1;
                i--;
            }
        }
        i--;
    }
}

int calc_sum(int *arr, int n) {
    int sum = 0;
    for (int i = 0; i < n; ++i) sum += arr[i];
    return sum;
}

int main() {
    string s;
    cin >> s;
    int arr[s.size() + 1];
    for (int i = 0; i < s.size() + 1; ++i) arr[i] = -1;
    set_zeroes(s, arr);
    fill_right(arr, s);
    fill_left(arr, s);
    cout << calc_sum(arr, s.size() + 1);
    return 0;
}
#include <iostream>
#include <string.h>

using namespace std;

void set_zeroes(string s, int *arr) {
    if (s[0] == '<') arr[0] = 0;
    if (s[s.size() - 1] == '>') arr[s.size()] = 0;
    for (int i = 0; i < s.size(); ++i) if (s[i] == '>' && s[i + 1] == '<') arr[i + 1] = 0;
}

void fill_right(int *arr, string s) {
    int i = 0;
    while (i < s.size()) {
        if (arr[i] == 0) {
            while (s[i] == '<') {
                arr[i + 1] = arr[i] + 1;
                i++;
            }
        }
        i++;
    }
}

void fill_left(int *arr, string s) {
    int i = s.size();
    while (i > 0) {
        if (arr[i] == 0) {
            while (s[i - 1] == '>') {
                if (arr[i] + 1 > arr[i - 1]) arr[i - 1] = arr[i] + 1;
                i--;
            }
        }
        i--;
    }
}

int calc_sum(int *arr, int n) {
    int sum = 0;
    for (int i = 0; i < n; ++i) sum += arr[i];
    return sum;
}

int main() {
    string s;
    cin >> s;
    int arr[s.size() + 1];
    for (int i = 0; i < s.size() + 1; ++i) arr[i] = -1;
    set_zeroes(s, arr);
    fill_right(arr, s);
    fill_left(arr, s);
    cout << calc_sum(arr, s.size() + 1);
    return 0;
}


Compiler output:
a.cc:60:6: error: redefinition of 'void set_zeroes(std::string, int*)'
   60 | void set_zeroes(string s, int *arr) {
      |      ^~~~~~~~~~
a.cc:6:6: note: 'void set_zeroes(std::string, int*)' previously defined here
    6 | void set_zeroes(string s, int *arr) {
      |      ^~~~~~~~~~
a.cc:66:6: error: redefinition of 'void fill_right(int*, std::string)'
   66 | void fill_right(int *arr, string s) {
      |      ^~~~~~~~~~
a.cc:12:6: note: 'void fill_right(int*, std::string)' previously defined here
   12 | void fill_right(int *arr, string s) {
      |      ^~~~~~~~~~
a.cc:79:6: error: redefinition of 'void fill_left(int*, std::string)'
   79 | void fill_left(int *arr, string s) {
      |      ^~~~~~~~~
a.cc:25:6: note: 'void fill_left(int*, std::string)' previously defined here
   25 | void fill_left(int *arr, string s) {
      |      ^~~~~~~~~
a.cc:92:5: error: redefinition of 'int calc_sum(int*, int)'
   92 | int calc_sum(int *arr, int n) {
      |     ^~~~~~~~
a.cc:38:5: note: 'int calc_sum(int*, int)' previously defined here
   38 | int calc_sum(int *arr, int n) {
      |     ^~~~~~~~
a.cc:98:5: error: redefinition of 'int main()'
   98 | int main() {
      |     ^~~~
a.cc:44:5: note: 'int main()' previously defined here
   44 | int main() {
      |     ^~~~