Problem:
 Score : 300 points    Problem Statement Given is a string S of length N-1 .
Each character in S is < or > .  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N , is said to be good when the following condition is satisfied for all i ( 1 \leq i \leq N-1 ):   If S_i=  < : a_i<a_{i+1}  If S_i=  > : a_i>a_{i+1}   Find the minimum possible sum of the elements of a good sequence of N non-negative integers.      Constraints  2 \leq N \leq 5 \times 10^5  S is a string of length N-1 consisting of < and > .         Input Input is given from Standard Input in the following format:  S       Output Find the minimum possible sum of the elements of a good sequence of N non-negative integers.        Sample Input 1 <>>      Sample Output 1 3  a=(0,2,1,0) is a good sequence whose sum is 3 .
There is no good sequence whose sum is less than 3 .       Sample Input 2 <>>><<><<<<<>>><      Sample Output 2 28

Solution (Python):
S = input()
a1 = [0] * (len(S) + 1)
a2 = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == '<':
        a1[i+1] = a1[i] + 1
    else:
        a1[i+1] = 0

for i in range(len(S)):
    
    if S[-i-1] == '>':
        a2[i+1] = a2[i] + 1
    else:
        a2[i+1] = 0

ans = 0
for i in range(len(S) + 1):
    ans += max(a1[i], a2[-i-1])
print(ans)

Solution (Python):
S = input()
N = len(S) + 1
Ans = [0]
a = 0
for c in S:
    if c=="<":
        a += 1
        Ans.append(a)
    else:
        a = 0
        Ans.append(a)

a = 0
for c, i in zip(S[::-1], range(N-2, -1, -1)):
    if c==">":
        a += 1
    else:
        a = 0
    Ans[i] = max(Ans[i], a)


print(sum(Ans))

Solution (Python):
s = input()
n = len(s) + 1
ans = [0] * n

tmp = 1
ens = list(enumerate(s))
for i, c in ens:
    if c == '<':
        ans[i + 1] = tmp
        tmp += 1
    else:
        tmp = 1

tmp = 1
for i, c in reversed(ens):
    if c == '>':
        ans[i] = max(ans[i], tmp)
        tmp += 1
    else:
        tmp = 1
print(sum(ans))

Solution (Python):
from itertools import groupby
x = input()
if x[0] == ">":
	x = "<" + x
if x[-1] == "<":
	x += ">"
l = [len(list(g)) for k, g in groupby(x)]
ans = 0
for i, j in zip(*[iter(l)] * 2):
	M = max(i, j)
	m = min(i, j)
	ans += M * (M + 1) // 2 + m * (m - 1) // 2
print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().rstrip().decode('utf-8')

N = len(S)+1

from_left = [0]*N
from_right = [0]*N

for i,s in enumerate(S,1):
    if s == '>':
        from_left[i] = 0
    else:
        from_left[i] = from_left[i-1]+1

for i,s in enumerate(S[::-1]):
    i = N-2-i
    if s == '<':
        from_right[i] = 0
    else:
        from_right[i] = from_right[i+1]+1

seq = [x if x>y else y for x,y in zip(from_left,from_right)]

answer = sum(seq)
print(answer)

Solution (Python):
s = input()
N = len(s) + 1

A = [0] * N
B = [0] * N

for i in range(1, N):
    if s[i-1] == "<":
        A[i] = A[i-1] + 1
for i in range(N-1)[::-1]:
    if s[i] == ">":
        B[i] = B[i+1] + 1

C = [max(A[i], B[i]) for i in range(N)]
print(sum(C))

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
N = len(S) + 1

ans = np.zeros(N,dtype=int)
cnt = 0
for i, c in enumerate(S, start=1):
    if c == '<':
        cnt += 1
    else:
        cnt = 0
    ans[i] = cnt
for i, c in enumerate(S[::-1], start=1):
    if c == '>':
        cnt += 1
    else:
        cnt = 0
    ans[~i] = max(cnt, ans[~i])
print(ans.sum())

Solution (Python):
import os
import sys
from collections import defaultdict as ddic, Counter, deque
from itertools import combinations, permutations, product
import bisect, heapq

FAST_INPUT = 0
if FAST_INPUT:
    from atexit import register
    from io import BytesIO
 
    sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
    sys.stdout = BytesIO()
    register(lambda: os.write(1, sys.stdout.getvalue()))
 
rr = lambda: sys.stdin.readline().rstrip('\r\n')
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
MOD = 10**9 + 7

DEBUG = 0
if DEBUG:
    import random
    random.seed(0)
    ri = random.randint



def solve(N, A):
    ans = [1] * N
    for i in range(N - 1):
        if S[i] == '<':
            ans[i+1] = ans[i] + 1
    
    for i in range(N - 2, -1, -1):
        if S[i] == '>':
            ans[i] = max(ans[i], ans[i+1] + 1)
    
    return sum(ans) - N
    

S = rr()
N = len(S)
print solve(N+1, S)