qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
S = input()
ans = 0
S = S.repace("><"/, ">,<").split(",")
for s in S:
  a = s.count(">")
  b = s.count("<")
  ans += a * (a - 1) // 2 + b * (b - 1) // 2 + max(a, b)
print(ans)

# Fixed code:
S = input()
ans = 0
S = S.replace("><", ">,<").split(",")
for s in S:
  a = s.count(">")
  b = s.count("<")
  ans += a * (a - 1) // 2 + b * (b - 1) // 2 + max(a, b)
print(ans)
# Buggy code:
s = input()
a = [-1 for i in range(len(s)+1)]
for i in range(len(s)-1):
    if s[i] == '>' and s[i+1] == "<":
        a[i+1] = 0
if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
def plus(i):
    j = i - 1
    while s[j] == '>':
        a[j] = max(a[j+1] + 1, a[j])
        j -= 1
        if j < 0:
            break
    j = i
    while s[j] == '<':
        a[j+1] = max(a[j] + 1, a[j+1])
        j += 1
        if  j == len(a) - 1:
            break
for i in range(len(a)):
    if a[i] == 0:
        plus(i)
print(sum(a))


# Fixed code:
s = input()
a = [-1 for i in range(len(s)+1)]
for i in range(len(s)-1):
    if s[i] == '>' and s[i+1] == "<":
        a[i+1] = 0
if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
def plus(i):
    j = i -1
    while j >= 0 and s[j] == '>':
        a[j] = max(a[j+1] + 1, a[j])
        j -= 1
    j = i
    if j == len(a) -1:
        return
    while s[j] == '<':
        a[j+1] = max(a[j] + 1, a[j+1])
        j += 1
        if  j == len(a) - 1:
            break
for i in range(len(a)):
    if a[i] == 0:
        plus(i)
print(sum(a))
# Buggy code:
s = input()
n = len(s) + 1
v = [0]*n

for i in range(n-1):
    if s[i] == "<":
        v[i+1] = v[i] + 1

for j in range(n-1):
    if s[-j-1] == ">":
        v[-j-2] = v[-j-1] + 1

print(sum(v))

# Fixed code:
s = input()
n = len(s) + 1
v = [0]*n

for i in range(n-1):
    if s[i] == "<":
        v[i+1] = v[i] + 1

for j in range(n-1):
    if s[-j-1] == ">":
        if v[-j-2] <= v[-j-1]:
            v[-j-2] = v[-j-1] + 1

print(sum(v))
# Buggy code:
s=input()
n=len(s)
ans=[0]*(n+1)
  
for i in range(0,n):
  if s[i]=='<':
    ans[i+1]=ans[i]+1
for i in range(n-1,-1,-1):
  if s[i]=='>':
    ans[i]=max(ans[i+1]+1,ans[i])
print(ans)
print(sum(ans))

# Fixed code:
s=input()
n=len(s)
ans=[0]*(n+1)
  
for i in range(0,n):
  if s[i]=='<':
    ans[i+1]=ans[i]+1
for i in range(n-1,-1,-1):
  if s[i]=='>':
    ans[i]=max(ans[i+1]+1,ans[i])
print(sum(ans))
# Buggy code:
S = input()
a = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)
for i in reversed(range(len(S))):
    if S[i] == '>':
        a[i] = max(a[i], a[i+1]-1)
ans = sum(a)

print(ans)

# Fixed code:
S = input()
a = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == '<':
        a[i + 1] = max(a[i + 1], a[i] + 1)
for i in reversed(range(len(S))):
    if S[i] == '>':
        a[i] = max(a[i], a[i + 1]+1)
ans = sum(a)

print(ans)
# Buggy code:
s=input()
ans=chk=0
ans=[-1]*(len(s)+1)
if s[0]=="<":
    ans[0]=0
if s[-1]==">":
    ans[-1]=0
for i in range(len(s)-1):
    if s[i]==">" and s[i+1]=="<":
        ans[i+1]=0
for i in range(len(s)):
    if s[i]=="<":
        ans[i+1]=ans[i]+1
for i in range(-1,-len(s)-1,-1):
    if s[i]==">":
        ans[i-1]=ans[i]+1
print(sum(ans))


# Fixed code:
s=input()
ans=chk=0
ans=[-1]*(len(s)+1)
if s[0]=="<":
    ans[0]=0
if s[-1]==">":
    ans[-1]=0
for i in range(len(s)-1):
    if s[i]==">" and s[i+1]=="<":
        ans[i+1]=0
for i in range(len(s)):
    if s[i]=="<":
        ans[i+1]=ans[i]+1
for i in range(-1,-len(s)-1,-1):
    if s[i]==">":
        ans[i-1]=max(ans[i-1],ans[i]+1)
print(sum(ans))
# Buggy code:
s = list(input())

lens = len(s)
if lens == 1:
  print(1)
  exit()
  
li = [0] * (len(s) + 1)
for itr, val in enumerate(s):
  if itr == 0:
    if val == "<":
      li[0] = 0
  else:
    if (s[itr - 1] == "<" and s[itr] == "<"):
      li[itr] = li[itr - 1] + 1
#    elif s[itr - 1] == ">" and s[itr] == "<":
#      li[itr] = 0
    if s[itr] == "<" and itr == lens - 1:
      li[itr + 1] = li[itr] + 1

for itr, val in enumerate(reversed(s)):
  if itr == 0:
    if val == ">":
      li[lens] = 0
  else:
    if s[lens - itr - 1] == ">" and s[lens - itr] == ">":
      li[lens - itr] = li[lens - itr + 1] + 1
    if s[0] == ">":
      li[0] = li[1] + 1
      
for itr, val in enumerate(s):
  if itr > 0:
    if s[itr - 1] == "<" and s[itr] == ">":
      li[itr] = max(li[itr - 1],li[itr + 1]) + 1 

print(li)
print(sum(li))

# Fixed code:
s = list(input())

lens = len(s)
if lens == 1:
  print(1)
  exit()
  
li = [0] * (len(s) + 1)
for itr, val in enumerate(s):
  if itr == 0:
    if val == "<":
      li[0] = 0
  else:
    if (s[itr - 1] == "<" and s[itr] == "<"):
      li[itr] = li[itr - 1] + 1
#    elif s[itr - 1] == ">" and s[itr] == "<":
#      li[itr] = 0
    if s[itr] == "<" and itr == lens - 1:
      li[itr + 1] = li[itr] + 1

for itr, val in enumerate(reversed(s)):
  if itr == 0:
    if val == ">":
      li[lens] = 0
  else:
    if s[lens - itr - 1] == ">" and s[lens - itr] == ">":
      li[lens - itr] = li[lens - itr + 1] + 1
    if s[0] == ">":
      li[0] = li[1] + 1
      
for itr, val in enumerate(s):
  if itr > 0:
    if s[itr - 1] == "<" and s[itr] == ">":
      li[itr] = max(li[itr - 1],li[itr + 1]) + 1 

print(sum(li))
# Buggy code:
s = str(input())
ans = 0
def leftmore(ln):
    ret = [0]
    cur = 0
    for c in ln:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    return ret

def rightless(ln):
    revl = reversed(ln)
    ret = [0]
    cur = 0
    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        ret.append(cur)
    return list(reversed(ret))

lm = leftmore(s)
rl = rightless(s)
print(lm)
print(rl)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)

# Fixed code:
s = str(input())
#s = "<>>><<><<<<<>>><"
ans = 0
def leftmore(ln):
    ret = [0]
    cur = 0
    for c in ln:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    return ret

def rightless(ln):
    revl = reversed(ln)
    ret = [0]
    cur = 0
    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        ret.append(cur)
    return list(reversed(ret))

lm = leftmore(s)
rl = rightless(s)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)
# Buggy code:
s=input()
n=len(s)+1
l=[0]*n
r=[0]*n
for i in range(n-1):
    if S[i]=='<': 
      l[i+1]=l[i]+1
    if S[n-2-i]=='>': 
      r[n-2-i]=r[n-1-i]+1
ans=0
for i in range(N):
  ans+=max(l[i],r[i])
print(ans)


# Fixed code:
s=input()
n=len(s)+1
l=[0]*n
r=[0]*n
for i in range(n-1):
    if s[i]=='<': 
      l[i+1]=l[i]+1
    if s[n-2-i]=='>': 
      r[n-2-i]=r[n-1-i]+1
ans=0
for i in range(n):
  ans+=max(l[i],r[i])
print(ans)
# Buggy code:
S = input()
a = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)
        print(a)

for i in range(1, len(S)):
    if S[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
        print(a)
print(sum(a))

# Fixed code:
S = input()
a = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)
        

for i in range(1, len(S)+1):
    if S[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
        
print(sum(a))
# Buggy code:
def main():
  s = input().rstrip('\n')
  n = len(s)
  dp = [0] * (1 + n)
  for i,c in enumerate(s):
    if c == '<':
      dp[i+1] = dp[i] + 1
  for i in range(n-1, -1, -1):
    if s[i] == '>':
      dp[i] = dp[i+1] + 1
  return sum(dp)

print(main())

# Fixed code:
def main():
  s = input().rstrip('\n')
  n = len(s)
  dp = [0] * (1 + n)
  for i,c in enumerate(s):
    if c == '<':
      dp[i+1] = dp[i] + 1
  for i in range(n-1, -1, -1):
    if s[i] == '>':
      dp[i] = max(dp[i], dp[i+1] + 1)
  return sum(dp)

print(main())
# Buggy code:
S = input()
n = len(S) + 1
num = [0] * n
for i in range(n-1):
    if S[i] == '<':
        num[i + 1] = max(num[i] + 1, num[i + 1])
for i in range(n - 2, -1, -1):
    if S[i] == '>':
        num[i] = max(num[i + 1] + 1, num[i])
print(sum(num))
print(num)


# Fixed code:
S = input()
n = len(S) + 1
num = [0] * n
for i in range(n-1):
    if S[i] == '<':
        num[i + 1] = max(num[i] + 1, num[i + 1])
for i in range(n - 2, -1, -1):
    if S[i] == '>':
        num[i] = max(num[i + 1] + 1, num[i])
print(sum(num))
# Buggy code:
s = input()
n = len(s) + 1
a = [0 for _ in range(n)]
for i in range(n-1):
    if s[i] == '<':
        a[i+1] = a[i] + 1
for i in reversed(range(1, n)):
    if s[i-1] == '>':
        a[i-1] = a[i]+1
print(sum(a))

# Fixed code:
s = input()
n = len(s) + 1
a = [0 for _ in range(n)]
for i in range(n-1):
    if s[i] == '<':
        a[i+1] = a[i] + 1
for i in reversed(range(1, n)):
    if s[i-1] == '>':
        a[i-1] = max(a[i-1], a[i]+1)
print(sum(a))
# Buggy code:
S=input()
N=len(S)
L=[0]*(N+1)
for i in range(len(S)):
    if S[i]=="<":
        L[i+1]+=L[i]+1

for i in range(len(S)-1,-1,-1):
    if S[i]==">":
        L[i]=max(L[i+1]+1,L[i])
print(L)
print(sum(L))

# Fixed code:
S=input()
N=len(S)
L=[0]*(N+1)
for i in range(len(S)):
    if S[i]=="<":
        L[i+1]+=L[i]+1

for i in range(len(S)-1,-1,-1):
    if S[i]==">":
        L[i]=max(L[i+1]+1,L[i])
print(sum(L))
# Buggy code:
S = input()
nums = [0] * (len(S)+1)
pos = 0
count = 0
pre_count = 0
now = '>'
for (i, s) in enumerate(S):
  if s != now:
    if s == '<':
      nums[pos] = max(pre_count, count)
      while pos != i:
        pos += 1
        count -= 1
        nums[pos] = count
    else:
      pos = i
      pre_count = count+1
      count = 1
    now = s
  else:
    count += 1
    if s == '<':
      nums[i] = count
if now == '<':
  nums[i+1] = count+1

print(sum(nums))

# Fixed code:
S = input()
nums = [0] * (len(S)+1)
pos = 0
count = 0
pre_count = 0
now = '>'
for (i, s) in enumerate(S):
  if s != now:
    if s == '<':
      nums[pos] = max(pre_count, count)
      while pos != i:
        pos += 1
        count -= 1
        nums[pos] = count
    else:
      pos = i
      pre_count = count+1
      count = 1
    now = s
  else:
    count += 1
    if s == '<':
      nums[i] = count
if now == '<':
  nums[i+1] = count+1

if s == '>':
  nums[pos] = max(pre_count, count)
  while pos != i+1:
    pos += 1
    count -= 1
    nums[pos] = count

print(sum(nums))
# Buggy code:
S = list(input())
N = len(S)

a = [0] * (N + 1)
for i in range(N):
    if S[i] == '<':
        a[i + 1] = max(a[i + 1], a[i] + 1)
    print(a)

for i in reversed(range(N)):
    if S[i] == '>':
        a[i] = max(a[i], a[i + 1] + 1)
    print(a)

print(sum(a))
print(a)


# Fixed code:
S = list(input())
N = len(S)

a = [0] * (N + 1)
for i in range(N):
    if S[i] == '<':
        a[i + 1] = max(a[i + 1], a[i] + 1)
    # print(a)

for i in reversed(range(N)):
    if S[i] == '>':
        a[i] = max(a[i], a[i + 1] + 1)
    # print(a)

print(sum(a))
# print(a)
# Buggy code:
s = input() + "<"

a = 0
b = 0
ans = 0
pre = s[0]

for i in s:
    print(ans, a, b)
    if i == ">":
        a += 1
        if pre == "<":
            ans += ((1 + b - 1) * (b - 1)) // 2
        pre = i
    if i == "<":
        if pre == ">":
            if b <= a:
                ans += ((1 + a) * a) // 2
            else:
                ans += ((1 + a - 1) * (a - 1)) // 2 + b
            a = 0
            b = 0
        b += 1
        pre = i
if i == "<":
    ans += ((1 + b - 1) * (b - 1)) // 2
print(ans)

# Fixed code:
s = input() + "<"

a = 0
b = 0
ans = 0
pre = s[0]

for i in s:
    if i == ">":
        a += 1
        if pre == "<":
            ans += ((1 + b - 1) * (b - 1)) // 2
        pre = i
    if i == "<":
        if pre == ">":
            if b <= a:
                ans += ((1 + a) * a) // 2
            else:
                ans += ((1 + a - 1) * (a - 1)) // 2 + b
            a = 0
            b = 0
        b += 1
        pre = i
if i == "<":
    ans += ((1 + b - 1) * (b - 1)) // 2
print(ans)
# Buggy code:
s = input()
n = len(s)
a = [0]*(n+1)
for i in range(n):
    if s[i] == '<':
        a[i+1] = a[i] + 1
for i in range(-1, -n, -1):
    if s[i] == '>':
        a[i-1] = a[i] + 1
print(sum(a))

# Fixed code:
s = input()
a = [0] * (len(s)+1)

for i in range(len(s)):
  if s[i] == "<":
    a[i+1] = a[i] + 1

for i in range(len(s)-1, -1, -1):
  if s[i] == ">":
    a[i] = max(a[i], a[i+1]+1)

print(sum(a))
# Buggy code:
from itertools import groupby, chain

def pairs(t):
    while True:
        x, y = next(t), next(t)
        a =[sum(1 for _ in g) for k, g in (x, y)]
        yield sum(x * (x - 1) // 2 for x in a) + max(a)

s = input()
t = groupby(s)
d = [(0, ())]
if s[0] == '<':
    t = chain(d, t)
if s[-1] == '>':
    t = chain(t, d)
print(sum(pairs(t)))



# Fixed code:
from itertools import groupby, chain, islice
 
def pairs(t):
    a = True
    while a:
        a =[sum(1 for _ in g) for k, g in islice(t, 2)]
        if a:
            yield sum(x * (x - 1) // 2 for x in a) + max(a)
 
s = input()
t = groupby(s)
d = [(0, ())]
if s[0] == '>':
    t = chain(d, t)
if s[-1] == '<':
    t = chain(t, d)
print(sum(pairs(t)))
# Buggy code:
n=int(input())
a=input()
p=0
q=0
r=0
i=0
while i<n-1:
  while a[i]=="<":
    i+=1
    p+=1
    if i==n-1:
      print(r+p*(p+1)//2)
      exit(0)
  while a[i]==">":
    i+=1
    q+=1
    if i==n-1:
      break
  r+=p*(p+1)//2+q*(q+1)//2-min(p,q)
  p=0
  q=0
print(r)

# Fixed code:
a=input()
n=len(a)
p=0
q=0
r=0
i=0
while i<n:
  while a[i]=="<":
    i+=1
    p+=1
    if i==n:
      print(r+p*(p+1)//2)
      exit(0)
  while a[i]==">":
    i+=1
    q+=1
    if i==n:
      break
  r+=p*(p+1)//2+q*(q+1)//2-min(p,q)
  p=0
  q=0
print(r)
# Buggy code:
s = input()
comp = []

cur = s[0]
streak = 0
count = 0

for i in range(len(s)):
    if s[i] == cur:
        streak += 1
    else:
        if (len(comp) == 0):
            if cur == ">":
                count += streak*(streak+1)//2
        else:
            if cur == ">":
                prevStreak = comp[-1][1]
                count += (prevStreak*(prevStreak+1) + streak*(streak+1)) // 2
                count -= min(streak, prevStreak)

        comp.append((cur, streak))
        streak = 1
        cur = s[i]

    if i == (len(s) - 1):
        if (len(comp) == 0):
            if cur == ">":
                count += streak*(streak+1)//2

        if cur == "<":
            count += streak*(streak+1)//2

print(count)

# Fixed code:
s = input() + "."
comp = []

cur = s[0]
streak = 0
count = 0

for i in range(len(s)):
    if s[i] == cur:
        streak += 1
    else:
        if (len(comp) == 0):
            if cur == ">":
                count += streak*(streak+1)//2
            elif i == (len(s) - 1):
                count += streak*(streak+1)//2
        elif cur == ">":
            prevStreak = comp[-1][1]
            count += (prevStreak*(prevStreak+1) + streak*(streak+1)) // 2
            count -= min(streak, prevStreak)
        elif i == (len(s) - 1):
            if cur == "<":
                count += streak*(streak+1)//2

        comp.append((cur, streak))
        streak = 1
        cur = s[i]

print(count)
# Buggy code:
S = input()
#print(len(S))
s_list = []
head_num = 10**6 if S[0] == ">" else 0
s_list.append(head_num)
for i in range(len(S)-1):
    if S[i] == ">" and S[i+1] == "<":
        s_list.append(0)
    elif S[i] == "<":
        s_list.append(s_list[i]+1)
    else:
        s_list.append(s_list[i]-1)
if S[len(S)-1] == "<":
    s_list.append(s_list[len(S)-1] +1)
else:
    s_list.append(s_list[len(S)-1] -1)

#print(s_list)
count = 1
for i in range(len(S)-1,-1,-1):
    if S[i] == ">" and S[i-1] == ">":
        s_list[i] = count
        count += 1
    else:
        count = 1
#print(len(s_list))
#print(s_list)

sum = 0
for i in range(len(s_list)):
    sum += s_list[i]

print(sum)
    

# Fixed code:
S = input()
#print(len(S))

if len(S) == 1:
    print("1")
    exit()

s_list = []
head_num = 10**6 if S[0] == ">" else 0
s_list.append(head_num)
for i in range(len(S)-1):
    if S[i] == ">" and S[i+1] == "<":
        s_list.append(0)
    elif S[i] == "<":
        s_list.append(s_list[i]+1)
    else:
        s_list.append(s_list[i]-1)
if S[len(S)-1] == "<":
    s_list.append(s_list[len(S)-1] +1)
else:
    s_list.append(s_list[len(S)-1] -1)

#print(s_list)
count = 1
s_list[len(s_list)-1] = 0 if s_list[len(s_list)-1] < 0 else s_list[len(s_list)-1] 
#print(s_list)
for i in range(len(S)-1,0,-1):
    if S[i] == ">" and S[i-1] == ">":
    #if S[i] == ">":
        s_list[i] = count
        count += 1
    elif S[i] == ">" and S[i-1] == "<":
        s_list[i] = max(s_list[i-1], s_list[i+1]) + 1
    else:
        count = 1

if S[0] == ">":
    s_list[0] = s_list[1] + 1
if S[len(S)-1] == ">":
    s_list[len(s_list)-1] =  0

#print(len(s_list))
#print(s_list)

sum = 0
for i in range(len(s_list)):
    sum += s_list[i]

print(sum)
# Buggy code:
s = input()
n = len(s) #length s
aa = ['.'] * (n + 1)

if s[0] == '<':
  aa[0] = 0
if s[-1] == '>':
  aa[-1] = 0

for i in range(n-1):
  if s[i] ==  '>' and s[i+1] == '<':
    aa[i+1] = 0 
  elif s[i] == '<' and s[i+1] == '>':
    aa[i+1] = n
    
z = [i for i,x in enumerate(aa) if x == 0]
m = [i for i, x in enumerate(aa) if x == n]


for i in range(len(z)-1):
  aa[m[i]] = max(m[i]-z[i], z[i+1]-m[i])
  aa[m[i]+1] = z[i+1]-m[i]-1
  for j in range(z[i]+1, m[i]):
    aa[j] = aa[j-1] +1
  for k in range(m[i]+2,z[i+1]):
    
    aa[k] = aa[k-1]-1
for i in range(z[-1], n+1):
  if aa[i] == '.':
    aa[i] = aa[i-1]+1
for i in range(z[0]):
  if aa[i] == '.':
    aa[i] = z[0] - i

# Fixed code:
s = input()
n = len(s) #length s
aa = ['.'] * (n + 1)

if s[0] == '<':
  aa[0] = 0
if s[-1] == '>':
  aa[-1] = 0

for i in range(n-1):
  if s[i] ==  '>' and s[i+1] == '<':
    aa[i+1] = 0 
  elif s[i] == '<' and s[i+1] == '>':
    aa[i+1] = n
    
z = [i for i,x in enumerate(aa) if x == 0]
m = [i for i, x in enumerate(aa) if x == n]


for i in range(len(z)-1):
  aa[m[i]] = max(m[i]-z[i], z[i+1]-m[i])
  aa[m[i]+1] = z[i+1]-m[i]-1
  for j in range(z[i]+1, m[i]):
    aa[j] = aa[j-1] +1
  for k in range(m[i]+2,z[i+1]):
    
    aa[k] = aa[k-1]-1
for i in range(z[-1], n+1):
  if aa[i] == '.':
    aa[i] = aa[i-1]+1
for i in range(z[0]):
  if aa[i] == '.':
    aa[i] = z[0] - i
    

print(sum(aa))
# Buggy code:
s = input()
n = len(s) + 1
ans = 0
l = 0
r = 0
if s[0] == ">":
    p = 0
elif s[0] == "<":
    p = 1
for i in range(n-1):
    if p == 0:
        if s[i] == ">":
            l += 1
        elif s[i] == "<":
            p = 1
            ans += l*(l+1)//2
            if l < r:
                ans -= l
            elif l >= r:
                ans -= r 
            l = 0
            r = 1
    elif p == 1:
        if s[i] == "<":
            r += 1
        elif s[i] == ">":
            l += 1
            p = 0
            ans += r*(r+1)//2
if r != 0:
    ans += r*(r+1)//2

print(ans)

# Fixed code:
s = input()
n = len(s) + 1
ans = 0
l = 0
r = 0
if s[0] == ">":
    p = 0
elif s[0] == "<":
    p = 1
for i in range(n-1):
    if p == 0:
        if s[i] == ">":
            l += 1
        elif s[i] == "<":
            p = 1
            ans += l*(l+1)//2
            if l < r:
                ans -= l
            elif l >= r:
                ans -= r 
            l = 0
            r = 1
    elif p == 1:
        if s[i] == "<":
            r += 1
        elif s[i] == ">":
            l += 1
            p = 0
            ans += r*(r+1)//2
if p == 0:
    ans += l*(l+1)//2
    if l < r:
        ans -= l
    elif l >= r:
        ans -= r
elif p == 1:
    ans += r*(r+1)//2
    
print(ans)
# Buggy code:
s = str(input())
num = [0 for _ in range(len(s)+1)]
for i in range(len(s)):
  if (s[i] == "<"):
    num[i+1] = num[i]+1
for i in range(len(s),1,-1):
  if (s[i-1] == ">"):
    num[i-1] == max(num[i-1],num[i]+1)
print(sum(num))

# Fixed code:
s = str(input())
ans = [0 for _ in range(len(s)+1)]
for i in range(len(s)):
    if(s[i] == '<'):
        ans[i+1] = ans[i]+1
for i in range(len(s),0,-1):
    if(s[i-1] == '>'):
        ans[i-1] = max(ans[i-1],ans[i]+1)
print(sum(ans))
# Buggy code:
def calc(n):
    return n * (n+1) / 2

S = list(input())

prev = S[0]
series = 1
l = []

for i in range(1, len(S)):
    if prev == S[i]:
        series += 1
    else:
        l.append((prev, series))
        prev = S[i]
        series = 1

l.append((prev, series))

prev_max = l[0][1]
prev = calc(prev_max)
res = prev

print(l)

for s, n in l[1::]:
    if s == '<':
        prev = calc(n)
        prev_max = n
        res += prev
    else:
        if n >= prev_max:
            res -= prev_max
            prev = calc(n)
            res += prev
        else:
            prev = calc(n-1)
            res += prev

    print(res)

print(int(res))


# Fixed code:
def calc(n):
    return n * (n+1) / 2

S = list(input())

prev = S[0]
series = 1
l = []

for i in range(1, len(S)):
    if prev == S[i]:
        series += 1
    else:
        l.append((prev, series))
        prev = S[i]
        series = 1

l.append((prev, series))

prev_max = l[0][1]
prev = calc(prev_max)
res = prev

for s, n in l[1::]:
    if s == '<':
        prev = calc(n)
        prev_max = n
        res += prev
    else:
        if n >= prev_max:
            res -= prev_max
            prev = calc(n)
            res += prev
        else:
            prev = calc(n-1)
            res += prev

print(int(res))
# Buggy code:
s=input()
sl=len(s)
a=[]
count=1
for i in range(sl-1):
    if s[i+1]==s[i]:
        count+=1
    else:
        a.append(count)
        count=1
a.append(count)
ans=0
al=len(a)
if s[0]=="<":
    for i in range(0,al-1,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        print(m,n)
        ans+=(m*(m+1)+n*(n-1))/2
    if al%2==1:
        ans+=a[-1]*(a[-1]+1)/2
elif s[0]==">":
    ans+=a[0]*(a[0]+1)/2
    for i in range(1,al-2,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        ans+=m*(m+1)*n*(n-1)/2
    if al%2==0:
        ans+=a[-1]*(a[-1]+1)/2
print(int(ans))

# Fixed code:
s=input()
sl=len(s)
a=[]
count=1
for i in range(sl-1):
    if s[i+1]==s[i]:
        count+=1
    else:
        a.append(count)
        count=1
a.append(count)
ans=0
al=len(a)
if s[0]=="<":
    for i in range(0,al-1,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        ans+=(m*(m+1)+n*(n-1))/2
    if al%2==1:
        ans+=a[-1]*(a[-1]+1)/2
elif s[0]==">":
    ans+=a[0]*(a[0]+1)/2
    for i in range(1,al-1,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        ans+=(m*(m+1)+n*(n-1))/2
    if al%2==0:
        ans+=a[-1]*(a[-1]+1)/2
print(int(ans))
# Buggy code:
s = input()
s0 = s[0]
count = 1
nodes = []
ans = 0
for i in range(1, len(s)):
  if s0 == s[i]:
    count += 1
  elif s0 == '>':
    s0 = s[i]
    nodes.append(-count)
    count = 1
  else:
    s0 = s[i]
    nodes.append(count)
    count = 1
if s0 == '>':
  nodes.append(-count)
else:
  nodes.append(count)
print(nodes)

for i in range(1, len(nodes)):
  if nodes[i] < 0:
    if abs(nodes[i]) > abs(nodes[i - 1]):
      nodes[i] = abs(nodes[i])
      nodes[i - 1] -= 1
    else:
      nodes[i] = abs(nodes[i])
      nodes[i] -= 1
nodes[0] = abs(nodes[0])
print(nodes)
for i in nodes:
  ans += (i * (i + 1)) // 2
print(ans)

# Fixed code:
s = input()
s0 = s[0]
count = 1
nodes = []
ans = 0
for i in range(1, len(s)):
  if s0 == s[i]:
    count += 1
  elif s0 == '>':
    s0 = s[i]
    nodes.append(-count)
    count = 1
  else:
    s0 = s[i]
    nodes.append(count)
    count = 1
if s0 == '>':
  nodes.append(-count)
else:
  nodes.append(count)

for i in range(1, len(nodes)):
  if nodes[i] < 0:
    if abs(nodes[i]) > abs(nodes[i - 1]):
      nodes[i] = abs(nodes[i])
      nodes[i - 1] -= 1
    else:
      nodes[i] = abs(nodes[i])
      nodes[i] -= 1
nodes[0] = abs(nodes[0])
for i in nodes:
  ans += (i * (i + 1)) // 2
print(ans)