Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    S = list(input())
    N = len(S) + 1
    a = []
    for i in range(N):
        a.append(calc(i, S))
    
    print(sum(a))

def calc(i, S):
    if i == 0:
        if S[i] == '<':
            return 0
        else:
            j = 0
            while j < len(S) and S[j] == '>':
                j += 1
            return j
    elif i == len(S):
        if S[i - 1] == '>':
            return 0
        else:
            j = 0
            while j < len(S) and S[i - 1 - j] == '<':
                j += 1
            return j
    else:
        j = 0
        while j < i and S[i - 1 - j] == '<':
            j += 1
        k = 0
        while (i + k) < len(S) and S[i + k] == '>':
            k += 1
        return max(j, k)

main()


Fixed submission:
def main():
    S = list(input())
    N = len(S) + 1
    a = [-1] * N
    for i in range(N):
        if a[i] == -1:
            calc(i, S, a)

    print(sum(a))

def calc(i, S, a):
    if i == 0:
        if S[i] == '<':
            a[i] = 0
        else:
            j = 0
            while j < len(S) and S[j] == '>':
                j += 1
            for k in range(j):
                a[k] = j - k
    elif i == len(S):
        if S[i - 1] == '>':
            a[i] = 0
        else:
            a[i] = a[i - 1] + 1
    else:
        if S[i - 1] == '<' and S[i] == '<':
            a[i] = a[i - 1] + 1
        elif S[i - 1] == '<' and S[i] == '>':
            j = 0
            while (i + j) < len(S) and S[i + j] == '>':
                j += 1
            for l in range(j):
                a[i + l] = j - l
            a[i] = max(a[i - 1] + 1, j)
        elif S[i - 1] == '>' and S[i] == '<':
            a[i] = 0
        elif S[i - 1] == '>' and S[i] == '>':
            a[i] = a[i - 1] - 1

main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    S = list(input())
    a = []
    for i in range(0, len(S) + 1):
        a.append(calc(i, S))
    
    total = 0
    for i in range(0, len(a)):
        total += a[i]
    
    print(total)

def calc(i, S):
    if i == 0:
        if S[i] == '<':
            return 0
        else:
            j = 0
            while j < len(S) and S[j] == '>':
                j += 1
            return j
    elif i == len(S):
        if S[i - 1] == '>':
            return 0
        else:
            j = 0
            while j < len(S) and S[i - 1 - j] == '<':
                j += 1
            return j
    else:
        j = 0
        while j < i and S[i - 1 - j] == '<':
            j += 1
        k = 0
        while (i + k) < len(S) and S[i + k] == '>':
            k += 1
        return max(j, k)

main()


Fixed submission:
def main():
    S = list(input())
    N = len(S) + 1
    a = [-1] * N
    for i in range(N):
        if a[i] == -1:
            calc(i, S, a)

    print(sum(a))

def calc(i, S, a):
    if i == 0:
        if S[i] == '<':
            a[i] = 0
        else:
            j = 0
            while j < len(S) and S[j] == '>':
                j += 1
            for k in range(j):
                a[k] = j - k
    elif i == len(S):
        if S[i - 1] == '>':
            a[i] = 0
        else:
            a[i] = a[i - 1] + 1
    else:
        if S[i - 1] == '<' and S[i] == '<':
            a[i] = a[i - 1] + 1
        elif S[i - 1] == '<' and S[i] == '>':
            j = 0
            while (i + j) < len(S) and S[i + j] == '>':
                j += 1
            for l in range(j):
                a[i + l] = j - l
            a[i] = max(a[i - 1] + 1, j)
        elif S[i - 1] == '>' and S[i] == '<':
            a[i] = 0
        elif S[i - 1] == '>' and S[i] == '>':
            a[i] = a[i - 1] - 1

main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    S = list(input())
    a = []
    for i in range(0, len(S) + 1):
        a.append(0)
    
    while True:
        change_count = 0
        for i in range(0, len(S)):
            if S[i] == '<' and a[i] >= a[i + 1]:
                a[i + 1] = a[i] + 1
                change_count += 1
            elif S[i] == '>' and a[i] <= a[i + 1]:
                a[i] += 1
                change_count += 1
        if change_count == 0:
            total = 0
            for i in range(0, len(a)):
                total += a[i]
            print(total)
            sys.exit()

main()


Fixed submission:
def main():
    S = list(input())
    N = len(S) + 1
    a = [-1] * N
    for i in range(N):
        if a[i] == -1:
            calc(i, S, a)

    print(sum(a))

def calc(i, S, a):
    if i == 0:
        if S[i] == '<':
            a[i] = 0
        else:
            j = 0
            while j < len(S) and S[j] == '>':
                j += 1
            for k in range(j):
                a[k] = j - k
    elif i == len(S):
        if S[i - 1] == '>':
            a[i] = 0
        else:
            a[i] = a[i - 1] + 1
    else:
        if S[i - 1] == '<' and S[i] == '<':
            a[i] = a[i - 1] + 1
        elif S[i - 1] == '<' and S[i] == '>':
            j = 0
            while (i + j) < len(S) and S[i + j] == '>':
                j += 1
            for l in range(j):
                a[i + l] = j - l
            a[i] = max(a[i - 1] + 1, j)
        elif S[i - 1] == '>' and S[i] == '<':
            a[i] = 0
        elif S[i - 1] == '>' and S[i] == '>':
            a[i] = a[i - 1] - 1

main()