Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
ll lcm(ll x, ll y) { return x/gcd(x, y)*y; }
ll mod_pow(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) { res = res * x % MOD; } x = x * x % MOD; y >>= 1; } return res; }
ll comb(ll n, ll k) { k = min(k, n - k); ll nnn = 1; for (ll i = n - k + 1; i <= n; i++) { nnn *= i; nnn %= MOD; } ll kkk = 1; for (ll i = 1; i <= k; i++) { kkk *= i; kkk %= MOD; } return (nnn * mod_pow(kkk, MOD - 2)) % MOD; }
ll to_int(string s) { ll n = s.size(); ll ans = 0; for (ll i = 0; i < n; i++) { ans = ((ans * 10) + (s[i] - '0')) % MOD; } return ans; }
bool is_prime(int n) { for(int i = 2; i*i <= n; i++) { if (n%i == 0) return false; } return n != 1; }

using Graph = vector<vector<pair<int, int>>>;
ll ni(int x){
    return x*(x+1)/2;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    
    string s;
    cin>>s;
    int n=s.size();
    vector<P> count(1000000);
    count[0].first=1;
    if(s[0]=='>'){
        count[0].sc=1;
    }
    int c=0;
    rep(i,n){
        if(i==0){
            continue;
        }
        if(s[i-1]==s[i]){
            count[c].first++;
        }
        else{
            c++;
            count[c].first++;
            if(s[i]=='>'){
                count[c].sc=1;
            }
        }
    }
    c++;
    ll ans=0;
    int x=c;
    c=0;
    if(count[0].sc==1){
        ans+=ni(count[0].fs);
        c=1;
    }
    Rep(i,c,x){
        if(count[i].sc==0){
            ans+=ni(count[i].fs);
        }
        else{
            ans+=ni(count[i].fs);
            ans-=min(count[i-1].fs,count[i].fs);
             }

    }
    cout<<ans<<endl;

}

Compiler output:
a.cc: In function 'll mod_pow(ll, ll)':
a.cc:20:83: error: 'MOD' was not declared in this scope
   20 | ll mod_pow(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) { res = res * x % MOD; } x = x * x % MOD; y >>= 1; } return res; }
      |                                                                                   ^~~
a.cc:20:102: error: 'MOD' was not declared in this scope
   20 | ll mod_pow(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) { res = res * x % MOD; } x = x * x % MOD; y >>= 1; } return res; }
      |                                                                                                      ^~~
a.cc: In function 'll comb(ll, ll)':
a.cc:21:109: error: 'MOD' was not declared in this scope
   21 | ll comb(ll n, ll k) { k = min(k, n - k); ll nnn = 1; for (ll i = n - k + 1; i <= n; i++) { nnn *= i; nnn %= MOD; } ll kkk = 1; for (ll i = 1; i <= k; i++) { kkk *= i; kkk %= MOD; } return (nnn * mod_pow(kkk, MOD - 2)) % MOD; }
      |                                                                                                             ^~~
a.cc:21:175: error: 'MOD' was not declared in this scope
   21 | ll comb(ll n, ll k) { k = min(k, n - k); ll nnn = 1; for (ll i = n - k + 1; i <= n; i++) { nnn *= i; nnn %= MOD; } ll kkk = 1; for (ll i = 1; i <= k; i++) { kkk *= i; kkk %= MOD; } return (nnn * mod_pow(kkk, MOD - 2)) % MOD; }
      |                                                                                                                                                                               ^~~
a.cc:21:209: error: 'MOD' was not declared in this scope
   21 | ll comb(ll n, ll k) { k = min(k, n - k); ll nnn = 1; for (ll i = n - k + 1; i <= n; i++) { nnn *= i; nnn %= MOD; } ll kkk = 1; for (ll i = 1; i <= k; i++) { kkk *= i; kkk %= MOD; } return (nnn * mod_pow(kkk, MOD - 2)) % MOD; }
      |                                                                                                                                                                                                                 ^~~
a.cc: In function 'll to_int(std::string)':
a.cc:22:117: error: 'MOD' was not declared in this scope
   22 | ll to_int(string s) { ll n = s.size(); ll ans = 0; for (ll i = 0; i < n; i++) { ans = ((ans * 10) + (s[i] - '0')) % MOD; } return ans; }
      |                                                                                                                     ^~~