Language: C++

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s) + 1;
    vector<ll> a;
    ll c = 0;
    char p = '*';
    REP(i, sz(s)) {
        if (p == s[i]) {
            c++;
        } else {
            if (p != '*') {
                a.push_back(c);
            }
            c = 1;
        }
        p = s[i];
    }

    a.push_back(c);

    REP(i, sz(a)) cout << a[i] << " ";
    cout << EOL;

    ll ans = 0;
    if (s[0] == '<') {
        for (int i = 0; i < sz(a) - 1; i += 2) {
            if (a[i] <= a[i + 1]) {
                ll x = a[i] - 1;
                ans += x * (x + 1) / 2;
                ll y = a[i + 1];
                ans += y * (y + 1) / 2;
            } else {
                ll x = a[i];
                ans += x * (x + 1) / 2;
                ll y = a[i + 1] - 1;
                ans += y * (y + 1) / 2;
            }
        }
        if (sz(a) % 2 != 0) {
            ll x = a[sz(a) - 1];
            ans += x * (x + 1) / 2;
        }

    } else {
        ll x = a[0];
        ans += x * (x + 1) / 2;

        for (int i = 1; i < sz(a) - 1; i += 2) {
            if (a[i] <= a[i + 1]) {
                ll x = a[i] - 1;
                ans += x * (x + 1) / 2;
                ll y = a[i + 1];
                ans += y * (y + 1) / 2;
            } else {
                ll x = a[i];
                ans += x * (x + 1) / 2;
                ll y = a[i + 1] - 1;
                ans += y * (y + 1) / 2;
            }
        }
        if (sz(a) % 2 == 0) {
            ll x = a[sz(a) - 1];
            ans += x * (x + 1) / 2;
        }
    }

    cout << ans << EOL;
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s) + 1;
    vector<ll> a;
    ll c = 0;
    char p = '*';
    REP(i, sz(s)) {
        if (p == s[i]) {
            c++;
        } else {
            if (p != '*') {
                a.push_back(c);
            }
            c = 1;
        }
        p = s[i];
    }

    a.push_back(c);

    REP(i, sz(a)) cout << a[i] << " ";
    cout << EOL;

    ll ans = 0;
    if (s[0] == '<') {
        for (int i = 0; i < sz(a) - 1; i += 2) {
            if (a[i] <= a[i + 1]) {
                ll x = a[i] - 1;
                ans += x * (x + 1) / 2;
                ll y = a[i + 1];
                ans += y * (y + 1) / 2;
            } else {
                ll x = a[i];
                ans += x * (x + 1) / 2;
                ll y = a[i + 1] - 1;
                ans += y * (y + 1) / 2;
            }
        }
        if (sz(a) % 2 != 0) {
            ll x = a[sz(a) - 1];
            ans += x * (x + 1) / 2;
        }

    } else {
        ll x = a[0];
        ans += x * (x + 1) / 2;

        for (int i = 1; i < sz(a) - 1; i += 2) {
            if (a[i] <= a[i + 1]) {
                ll x = a[i] - 1;
                ans += x * (x + 1) / 2;
                ll y = a[i + 1];
                ans += y * (y + 1) / 2;
            } else {
                ll x = a[i];
                ans += x * (x + 1) / 2;
                ll y = a[i + 1] - 1;
                ans += y * (y + 1) / 2;
            }
        }
        if (sz(a) % 2 == 0) {
            ll x = a[sz(a) - 1];
            ans += x * (x + 1) / 2;
        }
    }

    cout << ans << EOL;
}


Compiler output:
a.cc:109:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
  109 | template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:12:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
   12 | template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:110:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
  110 | template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:13:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
   13 | template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:111:11: error: redefinition of 'const int MOD'
  111 | const int MOD = 1000000007;
      |           ^~~
a.cc:14:11: note: 'const int MOD' previously defined here
   14 | const int MOD = 1000000007;
      |           ^~~
a.cc:112:11: error: redefinition of 'const int INF'
  112 | const int INF = 1000000001;
      |           ^~~
a.cc:15:11: note: 'const int INF' previously defined here
   15 | const int INF = 1000000001;
      |           ^~~
a.cc:113:10: error: redefinition of 'const ll LINF'
  113 | const ll LINF = 1000000001000000001LL;
      |          ^~~~
a.cc:16:10: note: 'const ll LINF' previously defined here
   16 | const ll LINF = 1000000001000000001LL;
      |          ^~~~
a.cc:114:12: error: redefinition of 'const char EOL'
  114 | const char EOL = '\n';
      |            ^~~
a.cc:17:12: note: 'const char EOL' previously defined here
   17 | const char EOL = '\n';
      |            ^~~
a.cc:118:5: error: redefinition of 'int main()'
  118 | int main() {
      |     ^~~~
a.cc:21:5: note: 'int main()' previously defined here
   21 | int main() {
      |     ^~~~
a.cc:126:6: error: redefinition of 'void solve()'
  126 | void solve() {
      |      ^~~~~
a.cc:29:6: note: 'void solve()' previously defined here
   29 | void solve() {
      |      ^~~~~