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



Sample input:
<>>


Sample output:
3

Submission status: Wrong Answer

Solution code:
s = input()
count = 0; memo = 0; x = 0
for i in range(1, len(s)):
    if s[i-1] == "<" and s[i] == ">":
        x += count*(count-1)//2
        memo = count
        count = 1
    elif s[i-1] == ">" and s[i] == "<":
        x += count*(count-1)//2+max(count, memo)
        memo = 0
        count = 1
    else:
        count += 1
else:
    if s[-1] == "<":
        x += count*(count+1)//2
    else:
        x += count*(count-1)//2+max(count, memo)
print(x)

Submission status: Wrong Answer

Solution code:
S = list(map(str,input()))
# s = "><<<<><<"
# S = list(map(str,s))
num = [-1]*(len(S)+1)
index0 = list()
than = 0# 0 == >, 1 == <
#----------------------------------------
for i in range(len(S)):
    if(S[i] == '<'):
        if(than == 0):
            num[i] = 0
            index0.append(i)
        than = 1
    else:
        than = 0
if(S[-1] == '>'):
    num[-1] = 0
    index0.append(len(S)+1)
#--------------------------------------
if(index0[0] == 0):
    i = 1
    while(True):
        num[i] = num[i-1]+1
        if(i >= len(S)):break
        if(S[i] == '>'):
            break
        i+=1
    index0.pop(0)
if(len(index0)>0):
    if(index0[-1] == len(S)+1):
        i = len(S)-1
        while(True):
            num[i] = num[i+1]+1
            i-=1
            if(i <= 0):break
            if(S[i] == '<'):break
        index0.pop(-1)
while(len(index0)>0):
        for i in reversed(range(0,index0[0])):
            if(S[i] == '<'):
                break
            num[i] = max(num[i],num[i+1]+1)
        for i in range(index0[0]+1,len(S)+1):
            num[i] = max(num[i],num[i-1]+1)
            if(i >= len(S)):break
            if(S[i]== '>'):break
        index0.pop(0)

ans = 0
for i in range(len(num)):
    ans += num[i]
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(map(str,input()))
# s = "><<<<><<"
# S = list(map(str,s))
num = [-1]*(len(S)+1)
index0 = list()
than = 0# 0 == >, 1 == <
#----------------------------------------
for i in range(len(S)):
    if(S[i] == '<'):
        if(than == 0):
            num[i] = 0
            index0.append(i)
        than = 1
    else:
        than = 0
if(S[-1] == '>'):
    num[-1] = 0
    index0.append(len(S)+1)
#--------------------------------------
if(index0[0] == 0):
    i = 1
    while(True):
        num[i] = max(num[i],num[i-1]+1)
        if(i >= len(S)):break
        if(S[i] == '>'):break
        i+=1
    index0.pop(0)
if(len(index0) > 0):
    if(index0[-1] == len(S)+1):
        i = len(S)-1
        while(True):
            num[i] = max(num[i],num[i+1]+1)
            i-=1
            if(i <= 0):break
            if(S[i] == '<'):break
        index0.pop(-1)
while(len(index0)>0):
        for i in reversed(range(0,index0[0])):
            if(i <= 0):break
            if(S[i] == '<'):break
            num[i] = max(num[i],num[i+1]+1)
        for i in range(index0[0]+1,len(S)+1):
            num[i] = max(num[i],num[i-1]+1)
            if(i >= len(S)):break
            if(S[i]== '>'):break
        index0.pop(0)

ans = 0
for i in range(len(num)):
    ans += num[i]
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(map(str,input()))
# s = "><<<<><<"
# S = list(map(str,s))
num = [-1]*(len(S)+1)
index0 = list()
than = 0# 0 == >, 1 == <
#----------------------------------------
for i in range(len(S)):
    if(S[i] == '<'):
        if(than == 0):
            num[i] = 0
            index0.append(i)
        than = 1
    else:
        than = 0
if(S[-1] == '>'):
    num[-1] = 0
    index0.append(len(S)+1)
#--------------------------------------
if(index0[0] == 0):
    i = 1
    while(True):
        num[i] = max(num[i],num[i-1]+1)
        if(i >= len(S)):break
        if(S[i] == '>'):break
        i+=1
    index0.pop(0)
if(len(index0) > 0):
    if(index0[-1] == len(S)+1):
        i = len(S)-1
        while(True):
            num[i] = max(num[i],num[i+1]+1)
            i-=1
            if(i <= 0):break
            if(S[i] == '<'):break
        index0.pop(-1)
if(len(index0) > 0):
    while(len(index0)>0):
            for i in reversed(range(0,index0[0])):
                if(i <= 0):break
                if(S[i] == '<'):break
                num[i] = max(num[i],num[i+1]+1)
            for i in range(index0[0]+1,len(S)+1):
                num[i] = max(num[i],num[i-1]+1)
                if(i >= len(S)):break
                if(S[i]== '>'):break
            index0.pop(0)

ans = 0
for i in range(len(num)):
    ans += num[i]
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(map(str,input()))
# s = "><<<<><<"
# S = list(map(str,s))
num = [-1]*(len(S)+1)
index0 = list()
than = 0# 0 == >, 1 == <
#----------------------------------------
for i in range(len(S)):
    if(S[i] == '<'):
        if(than == 0):
            num[i] = 0
            index0.append(i)
        than = 1
    else:
        than = 0
if(S[-1] == '>'):
    num[-1] = 0
    index0.append(len(S)+1)
#--------------------------------------
if(index0[0] == 0):
    i = 1
    while(True):
        num[i] = num[i-1]+1
        if(i >= len(S)):break
        if(S[i] == '>'):break
        i+=1
    index0.pop(0)
if(len(index0) != 0):
    if(index0[-1] == len(S)+1):
        i = len(S)-1
        while(True):
            num[i] = num[i+1]+1
            i-=1
            if(i <= 0):break
            if(S[i] == '<'):break
        index0.pop(-1)
if(len(index0) != 0):
    while(len(index0)>0):
            for i in reversed(range(0,index0[0])):
                if(i <= 0):break
                if(S[i] == '<'):break
                num[i] = max(num[i],num[i+1]+1)
            for i in range(index0[0]+1,len(S)+1):
                num[i] = max(num[i],num[i-1]+1)
                if(i >= len(S)):break
                if(S[i]== '>'):break
            index0.pop(0)

ans = 0
for i in range(len(num)):
    ans += num[i]
print(ans)

Submission status: Wrong Answer

Solution code:
S=list(str(input()))
ans=0
sofar=0
j=1
nax=0
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        ans+=j
        j+=1
    elif S[i]=='<' and S[i+1]=='>':
        ans+=j
        nax=j
        j=1    
    else:
        ans+=j
        if nax!=0:
            ans-=j
        j=1
        nax=0
    if j>nax:
        ans-=nax
        nax=0
ans+=j
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()

def sigma(n):
  return n*(n+1)//2

total=0
cnt=0
while s[0]=='>':
  cnt+=1
  s=s[1:]
  if s=='':
    break
total+=sigma(cnt)
  
flag=True
while flag:
  l=[]
  if '>' in s:
    for i in range(s.find('>')):
      l.append(s[i])
    s=s[s.find('>'):]
  else:
    l.extend(['<']*len(s))
    s=''
    flag=False
  if '<' in s:
    for i in range(s.find('<')):
      l.append(s[i])
    s=s[s.find('<'):]
  else:
    l.extend(['>']*len(s))
    s=''
    flag=False
  if l.count('<')<=l.count('>'):
    total+=sigma(l.count('>'))+sigma(l.count('<')-1)
  else:
    total+=sigma(l.count('<'))+sigma(l.count('>')-1)
  print(l)
print(total)

Submission status: Wrong Answer

Solution code:
S = input()
num = [0] * (len(S) + 1)
min_cnt = 0
plu_cnt = 0
flag = 0
ans = 0
if S[0] == ">":
    flag = 1
for i in range(len(S)):
    if flag == 1:
        if S[i] == "<":
            flag = 0
            plu_cnt = 0
        else:
            plu_cnt += 1
            ans += plu_cnt
    if S[i] == "<":
        if min_cnt == 0:
            plu_cnt += 1
        else: #ansに精算する
            M = max(plu_cnt, min_cnt)
            m = min(plu_cnt, min_cnt)
           # ans += ((plu_cnt+1)*plu_cnt)/2
           # ans += (min_cnt*(min_cnt-1))/2
            ans += ((M + 1) * M) // 2
            ans += (m*(m-1))//2
            plu_cnt, min_cnt = 0, 0
            plu_cnt += 1
    elif S[i] == ">" and flag == 0:
        min_cnt += 1
M = max(plu_cnt, min_cnt)
m = min(plu_cnt, min_cnt)
ans += ((M + 1) * M)//2
ans += (m*(m-1))//2
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
num = [0] * (len(S) + 1)
min_cnt = 0
plu_cnt = 0
flag = 0
ans = 0
if S[0] == ">":
    flag = 1
for i in range(len(S)):
    if flag == 1:
        if S[i] == "<":
            flag = 0
            plu_cnt = 0
        else:
            plu_cnt += 1
            ans += plu_cnt
    if S[i] == "<":
        if min_cnt == 0:
            plu_cnt += 1
        else: #ansに精算する
            M = max(plu_cnt, min_cnt)
            m = min(plu_cnt, min_cnt)
           # ans += ((plu_cnt+1)*plu_cnt)/2
           # ans += (min_cnt*(min_cnt-1))/2
            ans += ((M + 1) * M) // 2
            ans += (m*(m-1))//2
            plu_cnt, min_cnt = 0, 0
            plu_cnt += 1
    elif S[i] == ">" and flag == 0:
        min_cnt += 1
M = max(plu_cnt, min_cnt)
m = min(plu_cnt, min_cnt)
ans += ((M + 1) * M)//2
ans += (m*(m-1))//2
print(ans, plu_cnt, min_cnt)

Submission status: Wrong Answer

Solution code:
S = input()
a = [0]
for i in range(len(S)):
    if S[i] == '<':
        a.append(a[-1]+1)
    else:
        a.append(a[-1]-1)
i = 0
while i < len(a):
    if a[i] < 0 and a[i] < a[i-1] and ( i == len(a) -1 or a[i] < a[i+1] ):
        j = i
        while j > 0 and a[j-1] == a[j] + 1:
            j -= 1
        k = i
        while k < len(a)-1 and a[k+1] > a[k]:
            k += 1
        t = a[i]
        for l in range(j,k+1):
            a[l] -= t
        i = k
    elif a[i] > 0 and a[i] < a[i-1] and ( i == len(a) -1 or a[i] < a[i+1] ):
        j = i
        while j > 0 and a[j-1] > a[j]:
            j -= 1
        k = i
        while k < len(a)-1 and a[k+1] > a[k]:
            k += 1
        t = a[i]
        for l in range(j,k+1):
            if l == j and l > 0:
                a[l] -= min(t, a[l] - a[l-1] - 1)
            elif l == k and l < len(a) - 1:
                a[l] -= min(t, a[k] - a[k+1] - 1)
            else:
                a[l] -= t
        i = k
    i += 1
print(sum(a))

Submission status: Wrong Answer

Solution code:
S = input()
a = [0]
for i in range(len(S)):
    if S[i] == '<':
        a.append(a[-1]+1)
    else:
        a.append(a[-1]-1)
i = 0
while i < len(a):
    if a[i] != 0 and a[i] < a[i-1] and ( i == len(a) -1 or a[i] < a[i+1] ):
        j = i
        while j > 0 and a[j] + 1 == a[j-1] :
            j -= 1
        k = i
        while k < len(a)-1 and a[k] + 1 == a[k+1]:
            k += 1
        t = a[i]
        for l in range(j,k+1):
            a[l] -= t
        i = k
    i += 1
print(sum(a))

Submission status: Wrong Answer

Solution code:
S = input()
a = [0]
for i in range(len(S)):
    if S[i] == '<':
        a.append(a[-1]+1)
    else:
        a.append(a[-1]-1)
for i in range(len(a)):
    if a[i] != 0 and a[i-1] > a[i] and ( i == len(a) -1 or a[i+1] > a[i] ):
        j = i
        while j > 0 and a[j] + 1 == a[j-1] :
            j -= 1
        k = i
        while k < len(a)-1 and a[k] + 1 == a[k+1]:
            k += 1
        t = a[i]
        for l in range(j,k+1):
            a[l] -= t
        b = []
print(sum(a))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
s = input()
down = 0
ans = 0
tmp = 0
for i in s:
    print(ans)
    if i == "<":
        if down != 0:
            print(ans, tmp, down)
            if tmp >= down:
                ans += (down - 1) * (down - 2) // 2
            else:
                ans += -tmp + 1 + (down + 1) * down // 2
            down = 0
            tmp = 0
        ans += tmp
        tmp += 1
    else:
        down += 1
if down != 0:
    if tmp > down:
        ans += (down - 1) * (down - 2) // 2
    else:
        ans += -tmp + 1 + (down + 1) * down // 2
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)+1
ans = 0
ls = [0 for _ in range(n)]
rs = [0 for _ in range(n)]
for i in range(n-1):
    if s[i] == '<':
        ls[i+1] = ls[i]+1
for i in range(n-1):
    if s[i] == '>':
        rs[-2-i] = rs[-1-i]+1
for i,j in zip(ls,rs):
    ans += max(i,j)
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)

l = [0] * (N + 1)
r = [0] * (N + 1)

cnt_l = 0
for i in range(N):
  l[i] = cnt_l
  if S[i] == "<":
    cnt_l += 1
  else:
    cnt_l = 0
l[N - 1] = cnt_l

cnt_r = 0
for i in range(N):
  r[N-i] = cnt_r
  if S[N-1-i] == ">":
    cnt_r += 1
  else:
    cnt_r = 0
r[0] = cnt_r

a = [0] * (N+1)
for i in range(N + 1):
  a[i] = max(l[i], r[i])

print(sum(a))

Submission status: Wrong Answer

Solution 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 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)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution 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)):
    if S[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
print(sum(a))

Submission status: Wrong Answer

Solution 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))

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline


def main():
  S = input()[:-1] + '<'

  f = lambda N: N*(N+1)//2
  sum_ = 0
  prev = S[0]
  nb = 0
  nl = 0

  for i in range(1, len(S)):
    s = S[i]

    if s == '<':
      nb += 1
    elif s == '>':
      nl += 1

    if prev == '>' and s == '<':
      nb -= 1
      nl -= 1
      sum_ += (f(max(nb, nl)+1)+f(min(nb, nl)))
      # print(nb, nl, sum_)
      nb = 0
      nl = 0

    prev = s

  sum_ += f(nb)

  print(sum_)


if(__name__ == '__main__'):
  main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline


def main():
  S = '>' + input()[:-1] + '<'

  f = lambda N: N*(N+1)//2
  sum_ = -1
  prev = ''
  nb = 0
  nl = 0

  for i, s in enumerate(S):

    if s == '<':
      nb += 1
    elif s == '>':
      nl += 1

    if prev == '>' and s == '<':
      nb -= 1
      nl -= 1
      sum_ += (f(max(nb, nl)+1)+f(min(nb, nl)))
      # print(nb, nl, sum_)
      nb = 0
      nl = 0

    prev = s

  sum_ += f(nb)

  print(sum_)


if(__name__ == '__main__'):
  main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline


def main():
  S = input()[:-1]

  f = lambda N: N*(N+1)//2
  sum_ = 0
  prev = S[0]
  nb = 0
  nl = 0

  for i, s in enumerate(S):

    if s == '<':
      nb += 1
    elif s == '>':
      nl += 1

    if i == 0:
      prev = s
      continue

    if prev == '>' and s == '<':
      sum_ += (f(max(nb, nl))+f(min(nb, nl)-1))
      # print(nb, nl, sum_)
      nb = 0
      nl = 0

    prev = s

  sum_ += (f(max(nb, nl))+f(min(nb, nl)-1))

  print(sum_)


if(__name__ == '__main__'):
  main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline


def main():
  S = input()[:-1]

  f = lambda N: N*(N+1)//2
  sum_ = 0
  prev = S[0]
  nb = 0
  nl = 0
  flag = False
  for i in range(1, len(S)):
    s = S[i]
    if prev == '>' and s == '<':
      flag = True
      nl -= 1
      sum_ += (f(max(nb, nl)+1)+f(min(nb, nl)))
      # print(nb, nl, sum_)
      nb = 0
      nl = 0
    elif s == '<':
      nb += 1
    elif s == '>':
      nl += 1
    prev = s
  if not flag:
    if S[0] == '>':
      nl += 1
    else:
      nb += 1
    sum_ += (f(max(nb, nl))+f(min(nb, nl)-1))
  else:
    nl -= 1
    sum_ += (f(max(nb, nl)+1)+f(min(nb, nl)))

  print(sum_)


if(__name__ == '__main__'):
  main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline


def main():
  S = input()[:-1]

  f = lambda N: N*(N+1)//2
  sum_ = 0
  prev = S[0]
  nb = 0
  nl = 0
  # if prev == '>':
  #   nl += 1
  # else:
  #   nb += 1
  for i in range(1, len(S)):
    s = S[i]
    if prev == '>' and s == '<':
      nl -= 1
      sum_ += (f(max(nb, nl)+1)+f(min(nb, nl)))
      # print(nb, nl, sum_)
      nb = 0
      nl = 0
    elif s == '<':
      nb += 1
    elif s == '>':
      nl += 1
    prev = s
  nl -= 1
  sum_ += (f(max(nb, nl)+1)+f(min(nb, nl)))

  print(sum_)


if(__name__ == '__main__'):
  main()

Submission status: Wrong Answer

Solution code:
s = input()
l, count = [], 0
for i in s:
    if i=='>': count+=1
    else:
        if count: l.append(count)
        count = 0
if count: l.append(count); count = 0
j = 0
ans = []
if s[0]=='<':
    ans.append(0)
    for i in range(len(s)):
        if s[i]=='<': ans.append(ans[-1]+1)
        else:
            if l[j]==0: j+=1
            if ans[-1]>=l[j]:
                l[j]-=1
                ans.append(l[j])
                    
            else:
                ans[-1]=l[j]
                l[j]-=1
                ans.append(l[j])
    print(sum(ans))

else:
    ans.append(l[j])
    l[j]-=1
    for i in range(len(s)):
        if s[i]=='<': ans.append(ans[-1]+1)
        else:
            if l[j]==0: j+=1
            if j<len(l):
                
                if ans[-1]>=l[j]:
                    ans.append(l[j])
                    l[j]-=1
                    
                        
                else:
                    ans[-1]=l[j]
                    ans.append(l[j])
                    l[j]-=1
                    
            else: ans.append(0)
    print(sum(ans))

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
shift_max = [0]*(n+1)

big_run = 0
for i in range(n):
    if S[i] == '<':
        big_run += 1
    else:
        big_run = 0
    shift_max[i+1] = big_run
small_run = 0
for i in reversed(range(n)):
    if S[i] == '>':
        small_run += 1
    else:
        small_run = 0
    shift_max[i] = max(shift_max[i],small_run)

print(shift_max)
print(sum(shift_max))

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
inf = 10**9
l = [inf]*(n+1)
l[0] = 0
for i in range(n):
    if S[i] == '<':
        l[i+1] = l[i] + 1
    else:
        if i != n-1 and S[i+1] == '<':
            l[i+1] = 0
if l[n] == inf:
    l[n] = 0
l[n] = max(0,l[n])
for i in range(n-1,-1,-1):
    if S[i] == '<':
        l[i] = max(l[i+1]-1,l[i])
        if i != 0 and S[i-1] == '>':
            l[i] = 0
    else:
        if l[i] == inf:
            l[i] = l[i+1] + 1
        else:
            l[i] = max(l[i+1]+1,l[i])


print(sum(l))

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
inf = 10**9
l = [inf]*(n+1)
l[0] = 0
for i in range(n):
    if S[i] == '<':
        l[i+1] = l[i] + 1
    else:
        if i != n-1 and S[i+1] == '<':
            l[i+1] = 0
if l[n] == inf:
    l[n] = 0
l[n] = max(0,l[n])
for i in range(n-1,-1,-1):
    if S[i] == '<':
        l[i] = max(l[i+1]-1,l[i])
    else:
        if l[i] == inf:
            l[i] = l[i+1] + 1
        else:
            l[i] = max(l[i+1]+1,l[i])
l

print(sum(l))

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
inf = 10**9
l = [inf]*(n+1)
l[0] = 0
for i in range(n):
    if S[i] == '<':
        l[i+1] = l[i] + 1
    else:
        if i != n-1 and S[i+1] == '<':
            l[i+1] = 0
l[n] = max(0,l[n])
for i in range(n-1,0,-1):
    if S[i] == '<':
        l[i] = max(l[i+1]-1,l[i])
    else:
        if l[i] == inf:
            l[i] = l[i+1] + 1
        else:
            l[i] = max(l[i+1]+1,l[i])

print(sum(l))

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
inf = 10**9
l = [inf]*(n+1)
l[0] = 0
for i in range(n):
    if S[i] == '<':
        l[i+1] = l[i] + 1
    else:
        if i != n-1 and S[i+1] == '<':
            l[i+1] = 0
l[n] = max(0,l[n])
for i in range(n-1,0,-1):
    if S[i] == '<':
        l[i] = max(l[i+1]-1,l[i])
    else:
        if l[i] == inf:
            l[i] = l[i+1] + 1
        else:
            l[i] = max(l[i+1]+1,l[i])

print(l)
print(sum(l))

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
inf = 10**9
l = [inf]*(n+1)
if S[0] == '<':l[0] = 0
if S[n-1] == '>':l[n] = 0
for i in range(n-1):
    if S[i] == '<' and S[i+1] == '<':
        l[i+1], l[i+2] = l[i]+1, l[i]+2
    elif S[i] == '<' and S[i+1] == '>':
        l[i+1] = l[i]+1
    elif S[i] == '>' and S[i+1] == '<':
        l[i+1], l[i+2] = 0, 1
for i in range(n-1,0,-1):
    if S[i] == '>' and S[i-1] == '>':
        l[i], l[i-1] = l[i+1]+1, max(l[i+1]+2,l[i-1])
    elif S[i] == '>' and S[i-1] == '<':
        l[i] = max(l[i+1]+1,l[i])
    elif S[i] == '<' and S[i-1] == '>':
        if l[i-1] == inf: l[i-1] = 1
print(sum(l))

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
inf = 10**9
l = [inf]*(n+1)
if S[0] == '<':l[0] = 0
if S[n-1] == '>':l[n] = 0
for i in range(n-1):
    if S[i] == '<' and S[i+1] == '<':
        l[i+1], l[i+2] = l[i]+1, l[i]+2
    elif S[i] == '<' and S[i+1] == '>':
        l[i+1] = l[i]+1
    elif S[i] == '>' and S[i+1] == '<':
        l[i+1], l[i+2] = 0, 1
for i in range(n-1,0,-1):
    if S[i] == '>' and S[i-1] == '>':
        l[i], l[i-1] = l[i+1]+1, max(l[i+1]+2,l[i-1])
    elif S[i] == '>' and S[i-1] == '<':
        l[i] = max(l[i+1]+1,l[i])

print(sum(l))

Submission status: Wrong Answer

Solution 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, 0, -1):
    if S[i] == ">":
        A[i] = max(A[i], A[i+1]+1)

print(sum(A))

Submission status: Wrong Answer

Solution code:
S = input()
s_Count = 0
b_Count = 0
ans = 0

for i in range(len(S)):
  if S[i] == "<" and i != len(S)-1:
    s_Count += 1
  else:
    b_Count += 1
    if i == len(S)-1 or S[i+1] == "<":
      max_sb = max(s_Count,b_Count)
      min_sb = min(s_Count,b_Count) - 1
      ans += max_sb * (max_sb+1) / 2 + min_sb * (min_sb+1) / 2
      s_Count = 0
      b_Count = 0
print(int(ans))

Submission status: Wrong Answer

Solution code:
S = input()
left_s = S[0]
now = ''
S_list = []
for i, s in enumerate(S):
    if left_s != s:
        S_list.append(now)
        now = s
    else:
        now += s
    left_s = s
S_list.append(now)
sum = 0
if S_list[0][0] == '>':
    sum += len(S_list[0])
for i, s in enumerate(S_list):
    sum += (len(s))*(len(s)+1)//2
    if s[0] == '>':
        if len(S_list[i-1]) >= len(s):
            sum -= len(s)
        else:
            sum -= len(S_list[i-1])
print(int(sum))

Submission status: Wrong Answer

Solution code:
s = input()
a = []
ans = 0
for i in range(len(s)):
    dainari = 0
    syonari = 0
    for j in reversed(range(i)):
        if s[j] == "<":
            dainari += 1
        else:
            break
    for j in range(i,len(s)):
        if s[j] == ">":
            syonari += 1
        else:
            break
    ans += max(dainari,syonari)
    #print(max(dainari,syonari),s[i],a)
print(sum(a)+(s[-1] == "<"))

Submission status: Wrong Answer

Solution code:
S = input()
left_s = S[0]
now = ''
S_list = []
for i, s in enumerate(S):
    if left_s != s:
        S_list.append(now)
        now = s
    else:
        now += s
    left_s = s
S_list.append(now)
sum = 0
if S_list[0][0] == '>':
    sum += len(S_list[0])
for i, s in enumerate(S_list):
    if s[0] == '>':
        sum += (len(s)-1)*(len(s))/2
    else:
        sum += (len(s))*(len(s)+1)/2
        if i+1 != len(S_list) and len(S_list[i+1]) > len(s):
            sum += (len(S_list[i+1])-len(s))*len(s)
print(int(sum))

Submission status: Wrong Answer

Solution code:
s = input()
left, right = [0,], []
a, b = 0, 0

for i in range(len(s)):
    a = a+1 if s[i] == '<' else 0
    left.append(a)
    b = b+1 if s[-1*i] == '>' else 0
    right.append(b)

right.append(0)
right.reverse()
ans = sum(max(x, y) for x, y in zip(left, right))
print(ans)

Submission status: Wrong Answer

Solution code:
def left(x):
    a = 0
    while x-1 > 0 and s[x-1]=='<':
        a += 1
        x -= 1
    return a

def right(x):
    a = 0
    while x+1 < len(s) and s[x+1]=='>':
        a += 1
        x += 1
    return a

s = input()
ans = 0

for i in range(len(s)+1):
    ans += max(left(i), right(i))
print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)
s.append('<')
mini = 0
maxi = 0
p = 0

for i in range(n):
    if s[i] == '<':
        mini += 1
    else:
        maxi += 1
        if s[i+1] == '<':
            p += (1 + max(mini,maxi)) * max(mini,maxi) // 2
            p += (min(mini,maxi) - 1) * (min(mini,maxi) - 1) // 2
            mini = 0
            maxi = 0

if mini != 0:
    print(p + ((1+mini) * (mini) // 2))
else:
    print(p)

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)
s.append('<')
mini = 0
maxi = 0
p = 0

for i in range(n):
    if s[i] == '<':
        mini += 1
    else:
        maxi += 1
        if s[i+1] == '<':
            p += (1 + max(mini,maxi)) * max(mini,maxi) // 2
            mini = 0
            maxi = 0

print(p)

Submission status: Wrong Answer

Solution code:
s = input()

n = len(s)+1
L = [0]*(n)

for i in range(n-1):
  if s[i]=='<':
    L[i+1] = max(L[i+1],L[i]+1)

for i in range(n-2,0,-1):
  if s[i]=='>':
    L[i] = max(L[i],L[i+1]+1)
    
print(sum(L))

Submission status: Wrong Answer

Solution code:
s = input()

n = len(s)
L = [0]*(n+1)
for i in range(n-1):  
  if s[i]=='>' and s[i+1]=='<':
    j = i+1
    c = 1
    while j<n and s[j]=='<':
      L[j+1] = max(c,L[j+1])
      c += 1
      j += 1      
  
  j = i+1
  c = 1
  while j>=0 and s[j]=='>':
    L[j] = max(c,L[j])
    c += 1
    j -= 1            
    
print(sum(L))

Submission status: Wrong Answer

Solution code:
S = list(input().strip())
ans = [0] * len(S)
for i in range(len(S)):
    right = 0
    left = 0
    for l in range(i, -1, -1):
        if S[l] == "<":
            left += 1
        else:
            break
    for r in range(i+1, len(S)):
        if S[r] == ">":
            right += 1
        else:
            break
    ans[i] = max(right, left)

print(sum(ans))

Submission status: Wrong Answer

Solution code:
s=input()

#print(s.count(">"), s.count("<"))
#print(len(s))

ans=0
for i in range(1, s.count(">")+1):
  ans+=i
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

r = 0
l = 0
ans = 0
val = 0
for i in range(len(S)):
    if(S[i] == "<"):
        if(l == 1):
            r = 1
            if(val > l):
                ans += val
                val = 0
                l = 0
            else:
                ans += l
                l = 0
        elif(l > 1):
            if(val > l):
                ans += (l*(l+1))//2+(val-l)
                l = 0
                r = 1
                val = 0
            else:
                ans += (l*(l+1))//2
                l = 0
                r = 1
                val = 0
        else:
            r += 1
    else:
        if(r):
            ans += (r*(r-1))//2
            val = r
            l = 1
            r = 0
        else:
            l += 1
if(l):
    if(l == 1):
        ans += val
    else:
        if(val > l):
            ans += (l*(l+1))//2+(val-l)
        else:
            ans += (l*(l+1))//2
else:
    ans += (r*(r+1))//2
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

r = 0
l = 0
ans = 0
val = 0
for i in range(len(S)):
    if(S[i] == "<"):
        if(l == 1):
            r = 1
            ans += val
            val = 0
            l = 0
        elif(l > 1):
            if(val > l):
                ans += (l*(l+1))//2+(val-l)
                l = 0
                r = 1
                val = 0
            else:
                ans += (l*(l+1))//2
                l = 0
                r = 1
                val = 0
        else:
            r += 1
    else:
        if(r):
            ans += (r*(r-1))//2
            val = r
            l = 1
            r = 0
        else:
            l += 1
if(l):
    if(l == 1):
        ans += val
    else:
        if(val > l):
            ans += (l*(l+1))//2+(val-l)
        else:
            ans += (l*(l+1))//2
else:
    if(r):
        ans += (r*(r+1))//2
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

r = 0
l = 0
ans = 0
val = 0
for i in range(len(S)):
    if(S[i] == "<"):
        if(l == 1):
            r = 1
            ans += val
            val = 0
            l = 0
        elif(l > 1):
            if(val > l):
                ans += (l*(l+1))//2+(val-l)
                l = 0
                r = 1
                val = 0
            else:
                ans += (l*(l+1))//2
                l = 0
                r = 1
                val = 0
        else:
            r += 1
    else:
        if(r):
            ans += (r*(r-1))//2
            val = r
            l = 1
            r = 0
        else:
            l += 1
if(l):
    if(l == 1):
        ans += val
    else:
        if(val > l):
            ans += (l*(l+1))//2+(val-l)
        else:
            ans += (l*(l+1))//2
else:
    ans += (r*(r+1))//2
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
lst = []
cnt = 0
if S[0] == '<':
    flg = 0
else:
    flg = 1
for i in range(len(S)):
    if flg == 0:
        if S[i] == '<':
            cnt += 1
        elif S[i] == '>':
            lst.append(['<',cnt])
            cnt = 1
            flg = 1
    elif flg == 1:
        if S[i] == '<':
            lst.append(['>', cnt])
            cnt = 1
            flg = 0
        elif S[i] == '>':
            cnt += 1
if flg == 0:
    lst.append(['<',cnt])
else:
    lst.append(['>', cnt])
#print(lst)

ans = 0
for i in range(1,len(lst)):
    if lst[i-1][0] == '<' and lst[i][0] == '>':
       n = max(lst[i-1][1],lst[i][1])
       n2 = min(lst[i-1][1],lst[i][1])
       ans += n * (n+1) /2
       ans += (n2-1)*n2 / 2
if lst[0][0] == '>':
    ans+=1
elif lst[-1][0] == '<':
    ans+=1

print(int(ans))