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:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    s = input()

    g = []

    p = ' '
    o = 0
    for c in s:
        if p == c:
            o += 1 
        else:
            if p != ' ':
                g.append([p, o])
            o = 1
        p = c
    g.append([p, o])

    s = c = 0
    for i in g:
        if i[0] == '<':
            s += (i[1] * (2 * c + 1 + i[1])) // 2
            c += i[1]
        elif c < i[1]:
            s += (i[1] - c) + (i[1] * (i[1] - 1)) // 2
            c = 0
        else:
            s += (i[1] * (2 * c - i[1] - 1)) // 2
            c -= i[1]

    print(s)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
slist=list(input())
kosu=[]
n=len(slist)
counter=1
for i in range(n-1):
	if slist[i]==slist[i+1]:
		counter+=1
	else:
		kosu.append(counter)
		counter=1
kosu.append(counter)

nagasa=len(kosu)
kotae=0

if slist=="<":
	if nagasa%2==0:
		for i in range(0,nagasa,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
	else:
		for i in range(0,nagasa-1,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		kotae+=kosu[-1]*(kosu[-1]+1)/2
else:
	if nagasa%2!=0:
		for i in range(1,nagasa,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		kotae+=kosu[0]*(kosu[0]+1)/2
	else:
		for i in range(1,nagasa-1,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		kotae+=kosu[0]*(kosu[0]+1)/2
		kotae+=kosu[-1]*(kosu[-1]+1)/2
kotae=int(kotae)
print(kotae-1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

def count_L(S, N):
    ret=0
    for i in range(N):
        if S[i:i+1]=='>':
            ret+=1
        else:
            break
    return ret

def solve(S: str):
    a=[0]*(len(S))

    for i in range(len(S)-1):
        if S[i:i+1]=='<':
            if S[i+1:i+2]=='>': #a[i-1] < a[i] > a[i+1]
                a[i]=max(a[i-1]+1,count_L(S[i+1:],len(S[i+1:])))
            else:               #a[i-1] < a[i] < a[i+1]
                a[i]=a[i-1]+1
        else:
            if S[i+1:i+2]=='>': #a[i-1] > a[i] > a[i+1]
                a[i]=count_L(S[i+1:],len(S[i+1:]))
            else:               #a[i-1] > a[i] < a[i+1]
                a[i]=0
    if S[-1:]=='<':
        a[len(S)-1]=a[len(S)-2]+1

    print(sum(a))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)+1

ls = [0]*n
lsfg = [0]*n

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

for i in range(n-2):
    if s[i] != s[i+1]:
        if s[i] == "<":
            lsfg[i+1] = 1
        else:
            lsfg[i+1] = -1

m = min(ls)

for i in range(n):
    ls[i] = ls[i] + abs(m) 

for i in range(n-2):
    k = 0
    j = 0
    if s[i] != s[i+1]:
        if s[i] == ">":
            ls[i+1] = 0
        while i-k > 0:
            k += 1
            if s[i-k] == ">":
                ls[i-k+1] = k
            else:
                break
        while i+j < n-2:
            j += 1
            if s[i+j] == "<":
                ls[i+j+1] = j
            else:
                break

k = 0
j = 0

if s[0] =="<":
    ls[0] = 0
    while i+j < n-2:
            j += 1
            if s[i+j] == "<":
                ls[i+j+1] = j
            else:
                break
if s[n-2] == ">":
    ls[n-1] = 0
    while i-k > 0:
            k += 1
            if s[i-k] == ">":
                ls[i-k+1] = k
            else:
                break

ans = sum(ls)
print(ans)

Submission status: Wrong Answer

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

a = [0]*N
for i in range(N-1):
    if(s[i] == "<"):
        a[i+1] = a[i]+1

for j in range(N-2,0,-1):
    if(s[j] == ">"):
        if(a[j] <= a[j+1]):
            a[j] = a[j+1]+1

print(sum(a))

Submission status: Wrong Answer

Solution code:
import sys

inp = sys.stdin.readline()[:-1]
N = len(inp) - 1

ans = 0
curr = 0
less_row = 1
for c in inp:
    if c == "<":
        curr += 1
        ans += curr
        less_row = 1
    else:
        less_row -= curr - 1 > 0
        curr = min(0, curr - 1)
        ans += curr
        less_row += 1
        if curr < 0:
            curr += 1
            ans += less_row

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

def count_L(S, N):
    ret=0
    for i in range(N):
        if S[i:i+1]=='>':
            ret+=1
        else:
            break
    return ret

def solve(S: str):
    a=[0]*(len(S))

    for i in range(len(S)-1):
        if S[i:i+1]=='<':
            if S[i+1:i+2]=='>': #a[i-1] < a[i] > a[i+1]
                a[i]=max(a[i-1]+1,count_L(S[i+1:],len(S[i+1:])))
            else:               #a[i-1] < a[i] < a[i+1]
                a[i]=a[i-1]+1
        else:
            if S[i+1:i+2]=='>': #a[i-1] > a[i] > a[i+1]
                a[i]=count_L(S[i+1:],len(S[i+1:]))
            else:               #a[i-1] > a[i] < a[i+1]
                a[i]=0
    if S[-1:]=='<':
        a[len(S)-1]=a[len(S)-2]+1

    print(a,sum(a))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

S = input()
a = 0
sum_a = 0
min_a = 0
c = 0
for s in S:
    if s == '<':
        if c > a:
            sum_a += (1 + c) // 2 * (c + 1) - a
            a = 1
            c = 0
        elif c > 0:
            sum_a += (c + 1) // 2 * (c - 1)
            a = 1
            c = 0
        else:
            a += 1
            sum_a += a
            c = 0
    else:
        c += 1
else:
    if c > a:
        sum_a += (1 + c) // 2 * (c + 1) - a
        a = 1
        c = 0
    elif c > 0:
        sum_a += (c + 1) // 2 * (c - 1)
        a = 1
        c = 0

print(sum_a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = list(input().strip())
S.append("<")

L = [0] * len(S)
tmp = ">"

for i in range(len(S)):
    if tmp == ">" and S[i] == "<":
        L[i] == 0
    elif tmp == ">" and S[i] == ">":
        pass
    elif tmp == "<" and S[i] == "<":
        L[i] = L[i-1] + 1
    elif tmp == "<" and S[i] == ">":
        L[i] = L[i-1] + 1
    tmp = S[i]

tmp = S[-1]
for i in range(len(S)-2, -1, -1):
    if tmp == ">" and S[i] == "<":
        L[i+1] = max(L[i+1], L[i+2] + 1)
    elif tmp == ">" and S[i] == ">":
        L[i+1] = L[i+2] + 1
    elif tmp == "<" and S[i] == "<":
        pass
    elif tmp == "<" and S[i] == ">":
        pass
    tmp = S[i]

if S[0] == ">" and S[1] == ">":
    L[0] = L[1] + 1

print(sum(L))

Submission status: Wrong Answer

Solution code:
import math

S = input()
pad = []
left_flag = S[0] == "<"
count = 0
for k in S:
    if left_flag and k == "<":
        count += 1
    elif left_flag and k == ">":
        pad.append(count)
        left_flag ^= 1
        count = 1
    elif (not left_flag) and k == ">":
        count += 1
    else:
        pad.append(-count)
        left_flag ^= 1
        count = 1
if left_flag:
    pad.append(count)
else:
    pad.append(-count)


result = 0
for i, j in zip(pad[0::2], pad[1::2]):
    if i > abs(j):
        result += sum(range(i + 1)) + sum(range(abs(j)))
    else:
        result += sum(range(i)) + sum(range(abs(j) + 1))
if len(pad) % 2 == 1:
    result += pad[-1]
print(result)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) + 1
lis = [0] * n
if s[0] == "<":
  lis[0] = 0
p = 1
while p < n - 1:
  if s[p - 1] == ">" and s[p] == "<":
    lis[p] = 0
  elif s[p - 1] == "<" and s[p] == "<":
    lis[p] = max(lis[p - 1] + 1, lis[p])
  elif s[p] == ">":
    pass
  p += 1
    
if s[-1] == ">":
  lis[-2] = 1
  lis[-1] = 0
  
p = n - 3
while p > 0:
  if s[p] == ">" and s[p + 1] == "<":
    if p - 1 >= 0:
      lis[p] = max(lis[p + 1] + 1, lis[p], lis[p - 1] + 1)
    else:
      lis[p] = 1
  elif s[p] == ">" and s[p + 1] == ">":
    if p - 1 >= 0:
      lis[p] = max(lis[p + 1] + 1, lis[p], lis[p - 1] + 1)
    else:
      lis[p] = max(lis[p + 1] + 1, lis[p])
  elif s[p] == "<":
    pass
  p -= 1

if s[-1] == "<":
  lis[-1] = lis[-2] + 1
  
print(sum(lis))

Submission status: Wrong Answer

Solution code:
import sys

inp = sys.stdin.readline()[:-1]
N = len(inp) - 1

ans = 0
curr = 0
less_row = 1
for c in inp:
    if c == "<":
        curr += 1
        ans += curr
        less_row = 1
    else:
        less_row -= curr - 1 > 0
        curr = min(0, curr - 1)
        ans += curr
        less_row += 1
        if curr < 0:
            curr += 1
            ans += less_row

    print(c, curr, ans, less_row)

print(ans)

Submission status: Wrong Answer

Solution code:
S=list(input())
cnt=0

for i in range(len(S)):
    if S[i]!=S[i-1]:
        cnt+=5

if cnt<=10:
    print(cnt-7)
else:
    print(cnt-2)

Submission status: Wrong Answer

Solution code:
s = input()
t = s.split(">")
t2 = s.split("<")
a = []
b = []
for i in t:
    if i != '':
        a.append(i)

for i in t2:
    if i != '':
        b.append(i)
n = len(a)
n2 = len(b)
tmp = min(n, n2)
sums = 0
for i in range(tmp):
    x = len(a[i])
    y = len(b[i])
    if x > y:
        sums += (x * (x + 1)) / 2
        sums += (y * (y - 1)) / 2
    else:
        sums += (x * (x - 1)) / 2
        sums += (y * (y + 1)) / 2
if n > n2:
    x = len(a[n-1])
    sums += (x * (x + 1)) / 2
elif n2 > n:
    x = len(b[n2-1])
    sums += (x * (x + 1)) / 2

print(int(sums))

Submission status: Wrong Answer

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

n = [0]
for i in range(1, N + 1):
  n.append(n[-1] + i)

ans = 0
cnt_L = 0
cnt_R = 0
for i in range(N - 1):
  if i == 0:
    if S[i] == "<":
      cnt_L += 1
    else:
      cnt_R += 1
  elif S[i] != S[i - 1] and S[i] == "<":
    ans += n[max(cnt_L, cnt_R)] + n[min(cnt_L, cnt_R) - 1]
    cnt_L = 1
    cnt_R = 0
  else:
    if S[i] == "<":
      cnt_L += 1
    else:
      cnt_R += 1
if S[-1] == "<":
  ans += n[cnt_L]
else:
  if cnt_L > 0:
    ans += n[max(cnt_L, cnt_R)] + n[min(cnt_L, cnt_R) - 1]
  else:
    ans += n[cnt_R]
print(ans)

Submission status: Wrong Answer

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

A=[0]*(N+1)
L=[]
if S[0]=="<":
  r=1
  l=0
else:
  l=1
  r=0

for i in range(1,N):
  if S[i]=="<":
    r+=1
    if S[i]!=S[i-1]:
      L.append(-l)
      l=0
  else:
    l+=1
    if S[i]!=S[i-1]:
      L.append(r)
      r=0
if r>0:
  L.append(r)
elif l>0:
  L.append(-l)
      
m=max(abs(max(L)),abs(min(L)))
ans=0
if S[0]=="<":
  if len(L)%2==0:
    for i in range(len(L)//2):
      ma=max(L[2*i],-L[2*i+1])
      mi=min(L[2*i],-L[2*i+1])
      ans+=ma*(ma+1)//2+(mi-1)*mi//2
  else:
    for i in range(len(L)//2):
      ma=max(L[2*i],-L[2*i+1])
      mi=min(L[2*i],-L[2*i+1])
      ans+=ma*(ma+1)//2+(mi-1)*mi//2
    ans+=L[-1]*(L[-1]+1)//2
    
if S[0]==">":
  ans+=(-L[0])*(-L[0]+1)//2
  if len(L)%2==0:
    for i in range(len(L)//2-1):
      ma=max(L[2*i+1],-L[2*i+2])
      mi=min(L[2*i+1],-L[2*i+2])
      ans+=ma*(ma+1)//2+(mi-1)*mi//2
    ans+=L[-1]*(L[-1]+1)//2
  else:
    for i in range(len(L)//2):
      ma=max(L[2*i],-L[2*i+1])
      mi=min(L[2*i],-L[2*i+1])
      ans+=ma*(ma+1)//2+(mi-1)*mi//2

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = list(input().strip())
S.append("<")

L = [0] * len(S)
tmp = ">"

for i in range(len(S)):
    if tmp == ">" and S[i] == "<":
        L[i] == 0
    elif tmp == ">" and S[i] == ">":
        pass
    elif tmp == "<" and S[i] == "<":
        L[i] = L[i-1] + 1
    elif tmp == "<" and S[i] == ">":
        L[i] = L[i-1] + 1
    tmp = S[i]

tmp = S[-1]
for i in range(len(S)-2, -1, -1):
    if tmp == ">" and S[i] == "<":
        L[i+1] = max(L[i+1], L[i+2] + 1)
    elif tmp == ">" and S[i] == ">":
        L[i+1] = L[i+2] + 1
    elif tmp == "<" and S[i] == "<":
        pass
    elif tmp == "<" and S[i] == ">":
        pass
    tmp = S[i]

print(sum(L))

Submission status: Wrong Answer

Solution code:
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)

ans = [-1]*(N+1)
ans[0] = 0
ans[-1] = 0
tmp = 0
for i in range(N-1):
  if s[i] == "<":
    tmp += 1
    ans[i + 1] = tmp
  elif s[i] == ">" and s[i + 1] == "<":
    tmp = 0
    ans[i + 1] = tmp
else:
  if s[-1] == "<":
    ans[-1] = ans[-2] + 1

tmp = 0
for i in range(N-1,0,-1):
  if s[i] == ">":
    tmp += 1
    if s[i - 1] == "<":
      ans[i] = max(ans[i], tmp)
    else:
      ans[i] = tmp
  elif s[i] == "<" and s[i - 1] == ">":
    tmp = 0
    ans[i] = tmp

else:
  if s[0] == ">":
    ans[0] = ans[1]

print(sum(ans))

Submission status: Wrong Answer

Solution code:
import sys

inp = sys.stdin.readline()[:-1]
N = len(inp) - 1

ans = 0
curr = 0
less_row = 0
for c in inp:
    if c == "<":
        curr += 1
        ans += curr
        less_row = 1
    else:
        less_row -= curr - 1 > 0
        curr = min(0, curr - 1)
        ans += curr
        less_row += 1
        if curr < 0:
            curr += 1
            ans += less_row

    print(c, curr, ans, less_row)

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
l = [0 for i in range(len(s)+1)]
if s[0] == '<':
  cnt = 1
  for i in range(0, len(s)):
    if s[i] == '<':
      l[i+1] = max(cnt, l[i+1])
      cnt += 1
    else:
      break
if s[-1] == '>':
  cnt = 1
  for i in range(len(s)-1, -1, -1):
    if s[i] == '>':
      l[i] = max(cnt, l[i])
      cnt += 1
    else:
      break
for i in range(1, len(s)):
  if s[i-1:i+1] == '><':
    #左側検索
    cnt = 1
    for j in range(i-1, -1, -1):
      if s[j] == '>':
        l[j] = max(cnt, l[j])
        cnt += 1
      else:
        break
    #右側検索
    cnt = 1
    for j in range(i, len(s)):
      if s[j] == '<':
        l[j+1] = max(cnt, l[j])
        cnt += 1
      else:
        break
ans = sum(l)
print(ans)

Submission status: Wrong Answer

Solution code:
# for c in '03210120123452101':
# 3 2 5 2
s = input()
ans = 0
lst = [0]
if s[0] == '>':
    tmp = '>'
    cnt = 1
    lst[0] = len(s)
else:
    tmp = '<'
    cnt = 0
t = 0
for c in s:
    if tmp == c:
        cnt += 1
    else :
        if cnt > 1 or (c == '<' and lst[-1] == 1):
            if c == '<' and lst[-1] > cnt:
                cnt -= 1
            # print(c,cnt, t)
            ans += cnt * (cnt + 1) // 2
        lst.append(cnt)
        cnt = 1
    tmp = c
    t +=1
if cnt or (c == '>' and lst[-1] == 1):
    # print(cnt)
    ans += cnt * (cnt + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
S = str(input())
N = len(S) + 1
a = [0]*N
if '>' not in S or '<' not in S:
    print(N*(N+1)//2)
    exit()
res = 0
st = 1
if S[0] == '>':
    st = S.index('<')
    res += st*(st+1)//2
ed = 0
a = 0
b = 0
for i in range(st, N-1):
    if S[i-1] == '>' and S[i] == '<':
        res += max([a+1,b]) + a*(a+1)//2 + b*(b-1)//2
        if i==N-2:
            ed = -2
            break
        a = 0
        b = 0
        ed = i
    elif i==N-2 and S[i] == '>':
        res += max([a+1,b+1]) + a*(a+1)//2 + b*(b+1)//2
        ed = i
    elif S[i] == '<':
        a += 1
    elif S[i] == '>':
        b += 1
if ed == -2:
    res += 1
elif ed != N-2:
    res += (N+1-ed)*(N-ed)//2
print(res)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S) + 1
L = [0]
a = 0

for s in S:
    if s == '<':
        a += 1
        L.append(a)
    else:
        a -= 1
        L.append(a)

minimum = min(L)
L = [a-minimum for a in L]
L = [10 ** 6] + L + [10 ** 6]

for i in range(N):
    left = L[i]
    center = L[i + 1]
    right = L[i + 2]
    if left > center and center < right:
        L[i + 1] = 0
    else:
        L[i + 1] = min(left, right) + 1


for i in range(N):
    left = L[i]
    center = L[i + 1]
    right = L[i + 2]
    if left > center and center < right:
        L[i + 1] = 0
    else:
        L[i + 1] = min(left, right) + 1

L = L[1:-1]
print(sum(L))

Submission status: Wrong Answer

Solution code:
S = input()
count_1 = 0
count_2 = 0
count_max = 0
count_min = 0
counter = 0
for i in range(len(S)):
    if i != (len(S) - 1):
        if S[i] == "<":
            if count_2 == 0:
                count_1 += 1
                
            else:
                count_max = max(count_1,count_2)
                count_min = min(count_1,count_2)
                counter += ((count_max)*(count_max + 1) + (count_min)*(count_min - 1))/2
                count_1 = 1
                count_2 = 0

        elif S[i] == ">":
            count_2 += 1
            
    else:
        if S[i] == "<":
            count_max = max(count_1,count_2)
            count_min = min(count_1,count_2)
            counter += ((count_max)*(count_max + 1) + (count_min)*(count_min - 1))/2 + 1
        else:
            count_2 += 1
            count_max = max(count_1,count_2)
            count_min = min(count_1,count_2)
            counter += ((count_max)*(count_max + 1) + (count_min)*(count_min - 1))/2
            
print(int(counter))

Submission status: Wrong Answer

Solution code:
S = str(input())
N = len(S) + 1
a = [0]*N
if '>' not in S or '<' not in S:
    print(N*(N+1)//2)
    exit()
res = 0
st = 1
if S[0] == '>':
    st = S.index('<')
    res += st*(st-1)//2
ed = 0
a = 0
b = 0
for i in range(st, N-1):
    if S[i-1] == '>' and S[i] == '<':
        res += max([a+1,b]) + a*(a+1)//2 + b*(b-1)//2
        if i==N-2:
            ed = -2
            break
        a = 0
        b = 0
        ed = i
    elif i==N-2 and S[i] == '>':
        res += max([a+1,b+1]) + a*(a+1)//2 + b*(b+1)//2
        ed = i
    elif S[i] == '<':
        a += 1
    elif S[i] == '>':
        b += 1
if ed == -2:
    res += 1
elif ed != N-2:
    res += (N+1-ed)*(N-ed)//2
print(res)

Submission status: Wrong Answer

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

n = [0]
for i in range(1, N + 1):
  n.append(n[-1] + i)

ans = 0
cnt_L = 0
cnt_R = 0
for i in range(N - 1):
  if i == 0:
    if S[i] == "<":
      cnt_L += 1
    else:
      cnt_R += 1
  elif S[i] != S[i - 1] and S[i] == "<":
    ans += n[max(cnt_L, cnt_R)] + n[min(cnt_L, cnt_R) - 1]
    cnt_L = 1
    cnt_R = 0
  else:
    if S[i] == "<":
      cnt_L += 1
    else:
      cnt_R += 1
if S[-1] == "<":
  ans += n[cnt_L]
else:
  ans += n[max(cnt_L, cnt_R)] + n[min(cnt_L, cnt_R) - 1]
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
l = [0 for i in range(len(s)+1)]
if s[0] == '<':
  for i in range(0, len(s)):
    cnt = 1
    if s[i] == '<':
      l[i+1] = max(cnt, l[i+1])
      cnt += 1
    else:
      break
if s[-1] == '>':
  cnt = 1
  for i in range(len(s)-1, -1, -1):
    if s[i] == '>':
      l[i] = max(cnt, l[i])
      cnt += 1
    else:
      break
for i in range(1, len(s)):
  if s[i-1:i+1] == '><':
    #左側検索
    cnt = 1
    for j in range(i-1, -1, -1):
      if s[j] == '>':
        l[j] = max(cnt, l[j])
        cnt += 1
      else:
        break
    #右側検索
    cnt = 1
    for j in range(i, len(s)):
      if s[j] == '<':
        l[j+1] = max(cnt, l[j])
        cnt += 1
      else:
        break
ans = sum(l)
print(ans)

Submission status: Wrong Answer

Solution code:
#
import sys
import math
import numpy as np
import itertools

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
s = list(input())
t = [0]
now = 0
for i in range(len(s)):
#    print(i,t)
    if s[i]=='<':
        now += 1
        t.append(now)
    elif now == 0:
        now = -1
        t.append(now)
        if now == -1:
            t[i+1] += 1
            now += 1
            for j in range(i,-1,-1):
                if j==0:
                    t[j]=0
                elif t[j]==t[j+1]:
                    t[j] += 1
                else:
                    break
    else:
        now = 0
        t.append(now)

answer=0
for i in range(len(t)):
    answer += t[i]

print(answer)

Submission status: Wrong Answer

Solution code:
#
import sys
import math
import numpy as np
import itertools

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
s = list(input())
t = [0]
now = 0
for i in range(len(s)):
#    print(i,t)
    if s[i]=='<':
        now += 1
        t.append(now)
    elif now == 0:
        now = -1
        t.append(now)
        if now == -1:
            t[i+1] += 1
            now += 1
            for j in range(i,-1,-1):
                if j==0:
                    t[j]=0
                elif t[j]==t[j+1]:
                    t[j] += 1
                else:
                    break
    else:
        now = 0
        t.append(now)

answer=0
for i in range(len(t)):
    answer += t[i]

print(t,answer)

Submission status: Wrong Answer

Solution code:
S = str(input())
N = len(S) + 1

ans = 0

con = 0
mae = 10 ** 6
x = "a"
for i in range(N-1):
  if i == 0:
    con = 1
  else:
    if S[i] == x:
      con += 1
    else:
      ans += (1/2) * con * (con - 1) 
      if S[i] == "<":
        if mae < con:
          ans += con
        else:
          if mae != 10 ** 6:
            ans += mae
      #print(i, ans)
      x = S[i]
      mae = con
      con = 1
  #print(ans)

ans += (1/2) * con * (con + 1) 
if con == 1:
  if S[i] == ">":
    ans += mae

print(int(ans))

Submission status: Wrong Answer

Solution code:
S = input()

A = [0] * (len(S)+1)
B = [0] * (len(S)+1)

for i in range(len(S)):
    if S[i] == '<':
        A[i+1] = A[i] + 1
    else:
        A[i+1] = A[i] - 1
        if A[i+1] < 0:
            A[i+1] += 1
            for j in range(i, -1, -1):
                if S[j] == '>':
                    A[j] += 1
                else:
                    break
        if i+1 < len(S):
            if S[i+1] == '<':
                A[i+1] = 0

for i in range(len(S)):
    if S[i] == '>':
        if A[i] - A[i+1] != 1:
            for j in range(i, -1, -1):
                if S[j] == '>':
                    A[j] -= 1
                else:
                    break

print(sum(A))

Submission status: Wrong Answer

Solution code:
s = list(input())
s.append(" ")
n = len(s)
i = 0
ans = []
j = 1
while i<n-1:
    if s[i]==s[i+1]:
        i+=1
        j+=1
    else:
        ans.append([s[i],j])
        i+=1
        j =1
m = len(ans)
answer = 0
i = 0
while i<m:
    if i==m-1:
        answer+=1
        break
    
    if ans[i][0]=="<" and ans[i][1]>=ans[i+1][1]:
        x = ans[i][1]*(ans[i][1]+1)
        x = x//2
        answer +=x 
        y = ans[i+1][1]*(ans[i+1][1]-1)
        y = y//2
        answer +=y
        i+=2
    elif ans[i][0]=="<" and ans[i][1]<ans[i+1][1]:
        x = ans[i][1]*(ans[i][1]-1)
        x = x//2
        answer+=x
        y = ans[i+1][1]*(ans[i+1][1]+1)
        y = y//2
        answer +=y
        i +=2
    else:
        x = ans[i][1]*(ans[i][1]+1)
        x = x//2
        answer +=x
        i+=1
print(answer)

Submission status: Wrong Answer

Solution code:
s = input()

ans = 0
f = 0
be = -1
for k in range(len(s)):
    if be == -1:
        be = 0
    elif s[k] == '<':
        if f != 0 and be != 0:
            ans -= be * f
            be = 0
        ans += be + 1
        f = 0
        be += 1
    elif be ==0:
        f += 1
        ans += be + f
    else:
        f += 1
        ans += be - 1
        be = be - 1
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
l_strk_count = 1
r_strk_count = 1
ans = 0
pre_s = "a"
for i in s:
    
    if pre_s == "<" and i == "<":
        l_strk_count += 1
    elif pre_s == ">" and i == ">":
        r_strk_count += 1

    # if s != pre_s and l_strk_count =! 0 and r_strk_count == 0:
    #     ans += l_strk_count * (l_strk_count + 1) // 2
    if i == "<" and pre_s == ">":
        ans += (max(l_strk_count,r_strk_count) ** 2 + max(l_strk_count,r_strk_count))//2 + (min(l_strk_count,r_strk_count) ** 2 - min(l_strk_count,r_strk_count))//2
        l_strk_count = 1
        r_strk_count = 1
    pre_s = i
if pre_s == ">":
    ans += (max(l_strk_count,r_strk_count) ** 2 + max(l_strk_count,r_strk_count))//2 + (min(l_strk_count,r_strk_count) ** 2 - min(l_strk_count,r_strk_count))//2
else:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
import numpy as np
#import operator
import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	s=input().rstrip().decode('utf-8')
	n=len(s)
	if s[n-1]=="<":
		s+=">"
		n+=1
		print(s)
	
	dai=0
	syo=0
	
	ans=0
	s+="a"
	
	for i in range(n):
		if s[i]=="<":
			dai+=1
		elif s[i]==s[i+1]==">":
			syo+=1
		else:
			syo+=1
			deka=max(dai,syo)
			mini=min(dai,syo)-1
			ans+=deka*(deka+1)//2+(mini)*(mini+1)//2
			dai=syo=0
	print(ans)
	
	
if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
cnt1, cnt2 = 0, 0
a = []
if s[0] == '>':
    a.append(0)
for c in s:
    if c == '<':
        if cnt2:
            a.append(cnt2)
            cnt2 = 0
        cnt1 += 1
    else:
        if cnt1:
            a.append(cnt1)
            cnt1 = 0
        cnt2 += 1
if cnt1:
    a.append(cnt1)
else:
    a.append(cnt2)
for i in range(1, len(a), 2):
    ans += ((a[i] - 1) * a[i] + (a[i - 1] - 1) *
            a[i - 1]) // 2 + max(a[i], a[i - 1])
if len(a) % 2:
    ans += a[-1]
print(ans)

Submission status: Wrong Answer

Solution code:
def f(n):
    return n*(n+1)//2

import re
S=input()
T = re.findall('<+|>+', S)
while '' in T:
    T.remove('')
N=[len(i) for i in T]
sum_=0
if len(N) % 2 ==0:
    for i in range(len(N))[::2]:
        sum_ += f(max(N[i],N[i+1]))
        sum_ += f(min(N[i],N[i+1])-1)
else:
    for i in range(len(N)-1)[::2]:
        sum_ += f(max(N[i],N[i+1]))
        sum_ += f(min(N[i],N[i+1])-1)
    sum_ += f(N[-1])
print(sum_)

Submission status: Wrong Answer

Solution code:
s=list(input())
n=len(s)+1
f=1
s.append('!')
y=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        f+=1
    else:
        y.append(f)
        f=1
if len(y)==1:
    print(y[0]*(y[0]+1)//2)
    exit()
if s[0]=='<':
    ans=0
    for i in range(len(y)-1):
        ans+=y[i]*(y[i]-1)//2
        if i%2==0:
            ans+=max(y[i],y[i+1])
    if len(y)%2==0:
        ans+=y[-1]*(y[-1]-1)//2
    else:
        ans+=y[-1]*(y[-1]+1)//2
    print(ans)
else:
    ans=0
    for i in range(len(y)-1):
        ans+=y[i]*(y[i]-1)//2
        if i%2==1:
            ans+=max(y[i],y[i+1])
    if len(y)%2==0:
        ans+=y[-1]*(y[-1]+1)//2
    else:
        ans+=y[-1]*(y[-1]-1)//2
    print(ans)