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 python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    n = len(s)
    Llis = [0] * (n + 1)
    Rlis = [0] * (n + 1)
    for i in range(n):
        if s[i] == "<":
            Llis[i + 1] = 1
        else:
            Rlis[i] = 1
    for i in range(n):
        if Llis[i + 1] == 0:
            continue
        Llis[i + 1] += Llis[i]
    for i in range(n):
        if Rlis[-i - 1] == 0:
            continue
        Rlis[-i - 1] += Rlis[-i]
    ans = 0
    for i in range(n + 1):
        ans += max(Rlis[i], Llis[i])
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Wrong Answer

Solution code:
string=list(input())
N=len(string)
num=[0]*(N+1)
sum0=0

for i in range(N):
     if string[i]=="<":
          num[i+1]=num[i]+1
     else:
          if num[i]==0:
               num[i+1]=0
               for j in range(N):
                    num[i-j]+=1
                    if ((i-j-2)<0 or string[i-j-2]=="<"):
                         if num[i-j-1]<=num[i-j]:
                              num[i-j-1]=num[i-j]+1
                         break
sum0=0
for i in range(N+1):
     sum0=sum0+num[i]
print(sum0)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)+1
wa = 0
mini = 0
prev = 0
for i in range(len(s)):
  if s[i] == '<':
    prev += 1
    wa += prev
  else:
    prev -= 1
    wa += prev
    if prev < mini:
      mini = prev
print(wa-mini*n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
wa = 0
mini = 0
prev = 0
for i in range(len(s)):
  if s[i] == '<':
    prev += 1
    wa += prev
  else:
    prev -= 1
    wa += prev
    if prev < mini:
      mini = prev
print(wa-mini*n)

Submission status: Wrong Answer

Solution code:
s = input()
wa = 0
mini = 0
prev = 0
for i in range(1,len(s)):
  if s[i] == '<':
    prev += 1
    wa += prev
  else:
    prev -= 1
    wa += prev
    if prev < mini:
      mini = prev
print(wa-mini*len(s))

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,-1,-1):
  if s[i]==">":
    a[i]=a[i+1]+1
print(sum(a))

Submission status: Wrong Answer

Solution code:
s = input()
cur = 0
minn = 0
sumn = 0
for i in range(len(s)):
  if s[i]=="<":
    cur += 1
    sumn += cur
  elif s[i]==">":
    cur -= 1
    sumn += cur
    minn = min(minn,cur)
sumn += -1*minn*len(s)
print(sumn)

Submission status: Wrong Answer

Solution code:

import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter

import sys
def input():
	return sys.stdin.readline().strip()


S = input()

N = len(S) + 1

min_list = deque()
max_list = []
num = [-1]*N
if S[0] == "<":
	min_list.append(1)
	num[0] = 0
if S[-1] == ">":
	min_list.append(N - 2)
	num[N - 1] = 0
for i in range(1, N - 1):
	if S[i - 1] == ">" and S[i] == "<":
		min_list.append(i - 1)
		min_list.append(i + 1)
		num[i] = 0
	if S[i - 1] == "<" and S[i] == ">":
		max_list.append(i)

max_set = set(max_list)

while len(min_list) > 0:
	x = min_list.popleft()
	if x == 0:
		num[x] = num[x + 1] + 1
	elif x == N - 1:
		num[x] = num[x - 1] + 1
	elif not (S[i - 1] == "<" and S[i] == ">"):
		num[x] = max(num[x - 1], num[x + 1]) + 1
		if num[x - 1] == -1:
			min_list.append(x - 1)
		if num[x + 1] == -1:
			min_list.append(x + 1)

for x in max_list:
	num[x] = max(num[x - 1], num[x + 1]) + 1

print(sum(num))

Submission status: Wrong Answer

Solution code:
from itertools import groupby

s = input()
gr = groupby(s)

ans = 0
n_prev = 0
k_prev = '0'
for k, g in gr:
    n = len(list(g))
    n_sum = n * (n + 1) // 2 
    ans += n_sum
    if k_prev == '<' and n_prev < n:
        ans -= n_prev
    elif k_prev == '<' and n_prev > n:
        ans -= n
    n_prev = n
    k_prev = k

print(ans)

Submission status: Wrong Answer

Solution code:
s= input()
n=len(s)+1
l = []
ts = s[0]
f = 1
for i in range(1,n-1):
    if s[i] ==ts:
        f += 1
    else:
        l.append([ts,f])
        f = 1
        ts = s[i]
    if i == n-2:
        l.append([ts,f])

for i in range(len(l)):
    if l[i][0]=="<":
        if i < len(l)-1:
            if l[i][1] >= l[i+1][1]:
                l[i+1][1] -= 1
            else:
                l[i][1] -= 1

res = [(l[i][1]+1)*l[i][1]//2 for i in range(len(l))]
print(sum(res))

Submission status: Wrong Answer

Solution code:
S = input()
decom = []

temp = 0
for i in range(1,len(S)):
  if S[i] != S[i-1]:
    decom.append((S[i-1],temp + 1))
    temp = 0
  else:
    temp += 1
decom.append((S[-1],temp + 1))

ans = 0
for i in range(len(decom)):
  if decom[i][0] == "<":
    if i == len(decom):
      ans += decom[i][1]
    ans += int((decom[i][1] * (decom[i][1] - 1)) / 2)
  else:
    if i == 0 or decom[i][1] > decom[i-1][1]:
      ans += int((decom[i][1] * (decom[i][1] + 1)) / 2)
    else:
      ans += decom[i-1][1] + int((decom[i][1] * (decom[i][1] - 1)) / 2)
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
decom = []

temp = 0
for i in range(1,len(S)):
  if S[i] != S[i-1]:
    decom.append((S[i-1],temp + 1))
    temp = 0
  else:
    temp += 1
decom.append((S[-1],temp + 1))

ans = 0
for i in range(len(decom)):
  if decom[i][0] == "<":
    if i == len(decom):
      ans += decom[i][1]
    ans += int((decom[i][1] * (decom[i][1] - 1)) / 2)
  else:
    if i == 0 or decom[i][1] > decom[i-1][1]:
      ans += int((decom[i][1] * (decom[i][1] + 1)) / 2)
    else:
      ans += decom[i-1][1] + int((decom[i][1] * decom[i][1] - 1) / 2)
print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
k = 0
N = n.count(">")
k = sum(range(1,N+1,1))
print(k)

Submission status: Wrong Answer

Solution code:
n = input()
N = n.count(">")
print(sum(range(1,N+1,1)))

Submission status: Wrong Answer

Solution code:
def binSearch(N, A, key):
    left = 0
    right = N - 1
    k = (left + right) // 2
    while True:
        if key(A[k]):
            right = k
        else:
            left = k
        _k = (left + right) // 2
        if _k == k:
            return right
        else:
            k = _k


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


def calc(S):
    t = []
    i = S.find('><')
    while i != -1:
        t += [S[:i + 1]]
        S = S[i + 1:]
        i = S.find('><')
    t += [S]
    result = 0
    for u in t:
        nu = len(u)
        l = binSearch(nu, u, lambda c: c == '>')
        result += trisum(max(l, nu - l)) + trisum(min(l, nu - l) - 1)
    return result


S = input()
print(calc(S))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
S = input()
l1, l2 = [0], [0]
for i in range(len(S)):
    if S[i] == "<":
        l1.append(l1[-1] + 1)
    if S[i-1] == ">":
        l2.append(l2[-1] + 1)
# print(*l1)
# print(*l2)
print(min(sum(l1), sum(l2)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
S = input()
l1, l2 = [0], [0]
for i in range(len(S)):
    if S[i] == "<":
        l1.append(l1[-1] + 1)
    if S[i-1] == ">":
        l2.append(l2[-1] + 1)
print(sum(l2))

Submission status: Wrong Answer

Solution code:
s = input()
len_s = len(s)
ans_array = [0 for x in range(len_s+1)]
for index in range(len_s):
    if s[index] == "<":
        ans_array[index + 1] = ans_array[index]+1
print(ans_array)
for index in reversed(range(len_s)):
    if s[index] == ">":
        ans_array[index] = max(ans_array[index+1]+1, ans_array[index])
print(sum(ans_array))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
s=input().rstrip()
print(s)
ls=len(s)
L=[0]*(ls+1)

pre,n='<',0
for i,c in enumerate(s):
    if c=='<':
        if pre == '<':
            n+=1
            L[i+1]=n
        else:
            n=1
            L[i+1]=1
            pre='<'
    else:
        pre='>'

pre,n='>',0
for i,c in enumerate(s[::-1]):
    if c=='>':
        if pre == '>':
            n+=1
            L[ls-1-i]=max(n,L[ls-1-i])
        else:
            n=1
            L[ls-1-i]=max(n,L[ls-1-i])
            pre='>'
    else:
        pre='<'
print(sum(L))

Submission status: Wrong Answer

Solution code:
def perm_cul(N):
    return N * (N + 1) // 2
S = input()
N = len(S)
cnt_list = []
cnt = 1
ans = 0
if N == 1:
    print(1)
    exit()
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt += 1
    elif S[i] != S[i+1]:
        cnt_list.append(cnt)
        cnt = 1
    if i == N-2:
        cnt_list.append(cnt)
if S[0] == '<' and S[N-1] == '<':
    for i in range(len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])

elif S[0] == '<' and S[N-1] == '>':
    for i in range(len(cnt_list)):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])

elif S[0] == '>' and S[N-1] == '>':
    for i in range(len(cnt_list)):
        ans += perm_cul(cnt_list[i] - 1)
        if i % 2 == 0:
            ans += max(cnt_list[i-1], cnt_list[i])

else:
    for i in range(len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 0:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])
print(ans)

Submission status: Wrong Answer

Solution code:
def perm_cul(N):
    return N * (N + 1) // 2
S = input()
N = len(S)
cnt_list = []
cnt = 1
ans = 0
if N == 1:
    print(1)
    exit()
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt += 1
    elif S[i] != S[i+1]:
        cnt_list.append(cnt)
        cnt = 1
    if i == N-2:
        cnt_list.append(cnt)
if S[0] == '<' and S[N-1] == '<':
    for i in range(len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])

elif S[0] == '<' and S[N-1] == '>':
    for i in range(len(cnt_list)):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])

elif S[0] == '>' and S[N-1] == '>':
    for i in range(len(cnt_list)):
        ans += perm_cul(cnt_list[i] - 1)
        if i % 2 == 0:
            ans += max(cnt_list[i-1], cnt_list[i])

else:
    for i in range(len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])
print(ans)

Submission status: Wrong Answer

Solution code:
def perm_cul(N):
    return N * (N + 1) // 2
S = input()
N = len(S)
cnt_list = []
cnt = 1
ans = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt += 1
    elif S[i] != S[i+1]:
        cnt_list.append(cnt)
        cnt = 1
    if i == N-2:
        cnt_list.append(cnt)
if S[0] == '<' and S[N-1] == '<':
    for i in range(len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])

elif S[0] == '<' and S[N-1] == '>':
    for i in range(len(cnt_list)):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])

elif S[0] == '>' and S[N-1] == '>':
    for i in range(len(cnt_list)):
        ans += perm_cul(cnt_list[i] - 1)
        if i % 2 == 0:
            ans += max(cnt_list[i-1], cnt_list[i])

else:
    for i in range(len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])
print(ans)

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline
import math
#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True


def main():
#    h,w,a,b = map(int, input().split())
    s = input()
    a = [0]*(len(s)+1)
    print(a)
    a[0] = 0
    temp = 0
    for i in range(len(s)):
        if s[i] == "<":
            a[i + 1] = a[i]+ 1
            if temp>0:
                for j in range(temp+1):
                    a[i - j] = max(0 + j,a[i-j])
            temp = 0
        elif s[i] == ">" and i < len(s)-1:
            temp += 1
        else:
            temp+=1
            for j in range(temp):
                a[i - j] = 0 + j + 1

    b = 0
    for i in range(len(a)):
        b += a[i]

    print(b)




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline
import math
#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True


def main():
#    h,w,a,b = map(int, input().split())
    s = input()
    a = [0]*(len(s)+1)
    print(a)
    a[0] = 0
    temp = 0
    for i in range(len(s)):
        if s[i] == "<":
            a[i + 1] = a[i]+ 1
            if temp>0:
                for j in range(temp+1):
                    a[i - j] = max(0 + j,a[i-j])
            temp = 0
        elif s[i] == ">" and i < len(s)-1:
            temp += 1
        else:
            temp+=1
            for j in range(temp):
                a[i - j] = 0 + j + 1

    b = 0
    for i in range(len(a)):
        b += a[i]
    print(a)
    print(b)




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():

    S = input()
    i = 0
    cnt = []
    while i < len(S):
        ref = S[i]
        c = 0
        while i < len(S) and S[i] == ref:
            c += 1
            i += 1
        cnt.append(c)

    # print(cnt)
    ans = 0
    if S[0] == ">":
        ans += cnt[0] * (cnt[0] + 1) // 2
    cnt.pop(0)

    for i in range(len(cnt)):
        if i % 2 == 0:
            ans += cnt[i] * (cnt[i] + 1) // 2
        else:
            if cnt[i] > cnt[i-1]:
                ans += cnt[i] - cnt[i-1]
            ans += cnt[i] * (cnt[i] - 1) // 2

    return ans

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

Submission status: Wrong Answer

Solution code:
def main():

    S = input()
    i = 0
    cnt = []
    while i < len(S):
        ref = S[i]
        c = 0
        while i < len(S) and S[i] == ref:
            c += 1
            i += 1
        cnt.append(c)

    # print(cnt)
    ans = 0
    if S[0] == "<":
        for i in range(len(cnt)):
            if i % 2 == 0:
                ans += cnt[i] * (cnt[i] + 1) // 2
            else:
                if cnt[i-1] < cnt[i]:
                    ans += cnt[i] - cnt[i-1]
                ans += cnt[i] * (cnt[i] - 1) // 2
    else:
        for i in range(len(cnt)):
            if i == 0:
                ans += cnt[i] * (cnt[i] + 1) // 2
            if i % 2 == 1:
                ans += cnt[i] * (cnt[i] + 1) // 2
            else:
                if cnt[i-1] < cnt[i]:
                    ans += cnt[i] - cnt[i-1]
                ans += cnt[i] * (cnt[i] - 1) // 2

    return ans

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
s = list(input())

l = [0]*(len(s)+1)
c = 0
for i in range(len(s)):
  if s[i] == "<":
    c += 1
  else:
    c -= 1
  l[i+1] = c

m = min(l)
ans= 0
for i in range(len(l)):
  ans += l[i] - m

print(ans)

Submission status: Wrong Answer

Solution code:
def main():

    S = input()
    i = 0
    cnt = []
    while i < len(S):
        ref = S[i]
        c = 0
        while i < len(S) and S[i] == ref:
            c += 1
            i += 1
        cnt.append(c)

    # print(cnt)
    ans = 0
    if S[0] == "<":
        for i in range(len(cnt)):
            if i % 2 == 0:
                ans += cnt[i] * (cnt[i] + 1) // 2
            else:
                if cnt[i-1] < cnt[i]:
                    ans += cnt[i] - cnt[i-1]
                ans += cnt[i] * (cnt[i] - 1) // 2
    else:
        for i in range(len(cnt)):
            if i % 2 == 1:
                ans += cnt[i] * (cnt[i] + 1) // 2
            else:
                if cnt[i-1] < cnt[i]:
                    ans += cnt[i] - cnt[i-1]
                ans += cnt[i] * (cnt[i] - 1) // 2

    return ans

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

Submission status: Wrong Answer

Solution code:
S = input()
k = []
for i in range(len(S)):
    k.append(S[i])
if k.count(">")>k.count("<"):
    N = k.count(">")
    print(1/2*N*(N+1))
else:
    N = k.count(">")
    print(1/2*N*(N+1))

Submission status: Wrong Answer

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

s = input()
lc = 0
hc = 0
pre = None
ans = 0
for si in s:
    if pre == '>' and si == '<':
        if lc > hc:
            ans += acc(lc) + acc(max(hc - 1, 0))
        else:
            ans += acc(hc) + acc(max(lc -1, 0))
        lc, hc = 0, 0
    if si == '<':
        lc += 1
    else:
        hc += 1
ans += acc(hc)

print(ans)

Submission status: Wrong Answer

Solution code:
S = list ( input("") )
sum_list = [-100 for _ in range( len(S) + 1 )]
if S[0] == "<":
    sum_list[0] = 0
if S[len(S) - 1] == ">":
    sum_list[len(S)] = 0
for i in range( 1, len(S) ):
    before_check = i - 1
    after_check = i
    if S[before_check] == ">" and S[after_check] == "<":
        sum_list[i] = 0

a = list(sum_list)      
for i in range( 1, len(S) + 1 ):
    before_check = i - 1
    if a[i] == -100:
        if S[before_check] == "<":
            a[i] = a[i-1] + 1
            
b = list(sum_list)
for j in range( len(S)-1,0,-1  ):
    after_check = j
    if b[j] == -100:
        if S[after_check] == ">":
            b[j] = b[j+1] + 1 

answer = list()
for i in range(len(a)):
    answer.append(max(a[i],b[i]))
        
print(sum(answer))

Submission status: Wrong Answer

Solution code:
s = str(input())
m = len(s)
c = 0
r = 0
prevr = 0
s += "a"
if s[0] == "<":
  state = 1
else:
  state = -1
for i in range(1,m+1):
  if s[i] == s[i-1]:
    r += 1
  else:
    if state == 1:
      prevr = r
      c += ((r+2)*(r+1))//2
      state = -1
      r = 0
    else:
      c += ((r+2)*(r+1))//2
      if prevr >= r:
        c -= (r+1)
      else:
        c -= (prevr+1)
      state = 1
      r = 0
print(c)

Submission status: Wrong Answer

Solution code:
S = list ( input("") )
sum_list = [-100 for _ in range( len(S) + 1 )]
if S[0] == "<":
    sum_list[0] = 0
if S[len(S) - 1] == ">":
    sum_list[len(S)] = 0
for i in range( 1, len(S) ):
    before_check = i - 1
    after_check = i
    if S[before_check] == ">" and S[after_check] == "<":
        sum_list[i] = 0

a = list(sum_list)      
for i in range( 1, len(S) + 1 ):
    before_check = i - 1
    if a[i] == -100:
        if S[before_check] == "<":
            a[i] = a[i-1] + 1
            
b = list(sum_list)
for j in range( len(S)-1,0,-1  ):
    after_check = j
    if b[j] == -100:
        if S[after_check] == ">":
            b[j] = b[j+1] + 1 

answer = list()
for i in range(len(a)):
    if a[i] >= b[i]:
        answer.append(a[i])
    else:
        answer.append(b[i])

print(sum(answer))

Submission status: Wrong Answer

Solution code:
S = list ( input("") )
sum_list = [0 for _ in range( len(S) + 1 )]
if S[0] == "<":
    sum_list[0] = 0
if S[len(S) - 1] == ">":
    sum_list[len(S)] = 0
for i in range( 1, len(S) ):
    before_check = i - 1
    after_check = i
    if S[before_check] == ">" and S[after_check] == "<":
        sum_list[i] = 0

a = list(sum_list)      
for i in range( 1, len(S) + 1 ):
    before_check = i - 1
    if a[i] == 0:
        if S[before_check] == "<":
            a[i] = a[i-1] + 1
            
b = list(sum_list)
for j in range( len(S)-1,0,-1  ):
    after_check = j
    if b[j] == 0:
        if S[after_check] == ">":
            b[j] = b[j+1] + 1

answer = list()
for i in range(len(a)):
    if a[i] >= b[i]:
        answer.append(a[i])
    else:
        answer.append(b[i])
        
print(sum(answer))

Submission status: Wrong Answer

Solution code:
S = input()

list_num = []
S = "0" + S + "0"
def count_left(left_list):
    count = 0
    if len(left_list) == 0:
        return 0
    for i in reversed(left_list):
        if i == "<":
            count += 1
        else:
            return count

def count_right(right_list):
    count = 0
    if len(right_list) == 0:
        return 0
    for i in right_list:
        if i == ">":
            count += 1
        else:
            return count

for i in range(len(S)):
    left = count_left(S[0:i])
    right = count_right(S[i:])
    list_num.append(max(left,right))

sum_list = 0
for i in list_num:
    sum_list += i  

print(list_num)
print(sum_list)

Submission status: Wrong Answer

Solution code:
s = list(input())
s_len = len(s)
ans = [0]*(s_len+1)
for i in range(1,len(s)+1):
  if s[i-1] == ">":
    ans[i] = ans[i-1] - 1
  else:
    ans[i] = ans[i-1] + 1
ans_min = min(ans)
if ans_min < 0:
  ans = list(map(lambda x: x*2,ans))
print(sum(ans))

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 += int((1 + c) / 2 * c - a)
            a = 1
            sum_a += 1
            c = 0
        elif c > 0:
            sum_a += int((c) / 2 * (c - 1))
            a = 1
            sum_a += 1
            c = 0
        else:
            a += 1
            sum_a += a
            c = 0
    else:
        c += 1
else:
    if c > a:
        sum_a += int((1 + c) / 2 * c - a)
        a = 1
        c = 0
    elif c > 0:
        sum_a += int((c) / 2 * (c - 1))
        a = 1
        c = 0

print(sum_a)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
lis = [0]
n = len(s)
for i in range(n - 1):
    if s[i] != s[i + 1]:
        lis.append(i + 1)
lis.append(n)
n = len(lis) - 1
ans = 0
for i in range(n // 2):
    a, b = lis[i * 2 + 1] - lis[i * 2], lis[i * 2 + 2] - lis[i * 2 + 1]
    x, y = max(a, b), min(a, b)
    ans += x * (x + 1) // 2 + y * (y - 1) // 2
if n % 2 != 0:
    x = lis[-1] - lis[-2]
    ans += x * (x + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
lis = [0]
n = len(s)
for i in range(n - 1):
    if s[i] != s[i + 1]:
        lis.append(i + 1)
lis.append(n)
n = len(lis) - 1
ans = 0
for i in range(n // 2):
    a, b = lis[i * 2 + 1] - lis[i * 2], lis[i * 2 + 2] - lis[i * 2 + 1]
    x, y = max(a, b), min(a, b)
    ans += x * (x + 1) // 2 + y * (y - 1) // 2
    print(x, y, ans)
if n % 2 != 0:
    x = lis[-1] - lis[-2]
    ans += x * (x + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
d=[0]*(len(s)+1)
Z=[]
scount=0
ans=0
for i in range(1,len(s)-1):
  if s[i]==">":
    d[i+1]=0
    scount+=1
    Q=scount
    X=i
    if s[i-1]=="<":
      Z.append(i)
  elif s[i]=="<":
    d[i+1]=d[i]+1
    for j in range(scount):
      d[i-scount+j]=(scount-j)
    scount=0

if s[-1]==">":
  d[-1]=0
  scount+=1
  Q=scount
  X=len(s)-1    
if scount>0:
  for j in range(scount):
    d[X-scount+j+1]=Q
    Q-=1
for i in Z:
  d[i]=max(d[i+1]+1,d[i-1]+1)
  if i==0 and s[0]=="<":
    d[i]=0
if s[-1]=="<":
  d[-1]=d[-2]+1
if s[0]==">":
  d[0]=d[1]+1

print(sum(d))

Submission status: Wrong Answer

Solution code:
s=input()
d=[0]*(len(s)+1)
Z=[]
scount=0
ans=0
for i in range(1,len(s)-1):
  if s[i]==">":
    d[i+1]=0
    scount+=1
    Q=scount
    X=i
    if s[i-1]=="<":
      Z.append(i)
  elif s[i]=="<":
    d[i+1]=d[i]+1
    for j in range(scount):
      d[i-scount+j]=(scount-j)
    scount=0

if s[-1]==">":
  d[-1]=0
  scount+=1
  Q=scount
  X=len(s)-1    
if scount>0:
  for j in range(scount):
    d[X-scount+j+1]=Q
    Q-=1
for i in Z:
  d[i]=max(d[i+1]+1,d[i-1]+1)
  if i==0 and s[0]=="<":
    d[i]=0
if s[-1]=="<":
  d[-1]=d[-2]+1
if s[0]==">":
  d[0]=d[1]+1

print(d)

Submission status: Wrong Answer

Solution code:
s=input()
d=[0]*(len(s)+1)
Z=[]
scount=0
ans=0
for i in range(1,len(s)-1):
  if s[i]==">":
    d[i+1]=0
    scount+=1
    Q=scount
    X=i
    if s[i-1]=="<":
      Z.append(i)
  elif s[i]=="<":
    d[i+1]=d[i]+1
    for j in range(scount):
      d[i-scount+j]=(scount-j)
    scount=0

if s[-1]==">":
  d[-1]=0
  scount+=1
  Q=scount
  X=len(s)-1    
if scount>0:
  for j in range(scount):
    d[X-scount+j+1]=Q
    Q-=1
for i in Z:
  d[i]=max(d[i+1]+1,d[i-1]+1)
  if i==0 and s[0]=="<":
    d[i]=0
if s[-1]=="<":
  d[-1]=d[-2]+1

print(sum(d))

Submission status: Wrong Answer

Solution code:
S = input()
slst = [[] for _ in range(len(S) + 1)]
tmp = S[0]
cnt = 0
index = 0
for i in range(len(S)):
    if tmp == S[i]:
        cnt += 1
    else:
        slst[index].append(tmp)
        slst[index].append(cnt)
        index += 1
        tmp = S[i]
        cnt = 1

slst[index].append(tmp)
slst[index].append(cnt)

dp = [0] * (len(S) + 1)
if slst[0][0] == '<':
    dp[0] = 0
else:
    dp[0] = slst[0][1]

index = 1
for i in range(len(S)):
    if slst[i] == []:
        break

    if slst[i][0] == '>':
        dp[index] = dp[index - 1] + ((slst[i][1]) * ((slst[i][1] - 1))) // 2
        index += 1
    else:
        if slst[i + 1] == []:
            dp[index] = dp[index - 1] + ((slst[i][1] + 1) * ((slst[i][1]))) // 2
            index += 1
        else:
            if slst[i][1] < slst[i + 1][1]:
                tdp = 0
                for k in range(slst[i][1]):
                    tdp += slst[i + 1][1] - k
                dp[index] = dp[index - 1] + tdp
                index += 1

            else:
                dp[index] = dp[index - 1] + ((slst[i][1] + 1) * ((slst[i][1]))) // 2
                index += 1


print(dp[index - 1])

Submission status: Wrong Answer

Solution code:
S = list(input())
zeroone = [2]
for i in range(len(S)):
    if S[i] == "<":
        zeroone.append(1)
    else:
        zeroone.append(-1)
zeroone.append(2)

cnt = [0]
for i in range(len(zeroone)-1):
    if zeroone[i+1] != zeroone[i]:
        cnt.append(i+1)
cnt.append(len(zeroone))

ans = [0] * (len(zeroone)+1)
ans[0] = ans[-1] = 1000000

for i in range(len(zeroone)-1):
    if zeroone[i+1] - zeroone[i] > 0:
        ans[i+1] = 0
        for j in range(i+1, cnt[cnt.index(i+1) + 1]):
            ans[j+1] = ans[j] + 1

        for k in range(cnt[cnt.index(i+1) - 1], i+1)[::-1]:
            ans[k] = max(ans[k+1] + 1, ans[k])

print(sum(ans[1:-1]))

Submission status: Wrong Answer

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

a = [0]*N
#foward
for i, s in enumerate(S):
  if s=="<":
    a[i+1]=a[i]+1
#back
S_ = list(reversed(S))
j=0
for s in S_:
  if s==">":
    a[N-1-j-1]=a[N-1-j]+1
  j+=1
print(sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
slst = [[] for _ in range(len(S) + 1)]
tmp = S[0]
cnt = 0
index = 0
for i in range(len(S)):
    if tmp == S[i]:
        cnt += 1
    else:
        slst[index].append(tmp)
        slst[index].append(cnt)
        index += 1
        tmp = S[i]
        cnt = 1

slst[index].append(tmp)
slst[index].append(cnt)

dp = [0] * (len(S) + 1)

dp[0] = 0

index = 1
tmpv = dp[0]
tmpi = 0
for i in range(len(S)):
    if slst[i] == []:
        break

    if slst[i][0] == '>':
        dp[index] = dp[index - 1] + ((slst[i][1]) * ((slst[i][1] - 1))) // 2
        index += 1
    else:
        if slst[i + 1] == []:
            dp[index] = dp[index - 1] + ((slst[i][1] + 1) * ((slst[i][1]))) // 2
            index += 1
        else:
            if slst[i][1] < slst[i + 1][1]:
                tdp = 0
                for k in range(slst[i][1]):
                    tdp += slst[i + 1][1] - k
                dp[index] = dp[index - 1] + tdp
                index += 1

            else:
                dp[index] = dp[index - 1] + ((slst[i][1] + 1) * ((slst[i][1]))) // 2
                index += 1


print(dp[index - 1])

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

S = list(input())
N = len(S)+1
if N%2==0:
    D = np.zeros(N)
else:
    D = np.zeros(N-1)
   
nc = 1
cur = S[0]
curi = 0
for i in range(1,N-1):
    if S[i]==cur:
        nc += 1
    else:
        D[curi] = nc
        cur = S[i]
        curi += 1
        nc = 1
D[curi] = nc
D=D.reshape([-1,2])
Asum = 0
for d in D:
    if d.all == 0:
        break
    else:
        a1 = max(d)
        a2 = min(d)
        Asum += int((a1+1)*a1/2 + a2*(a2-1)/2)

print(Asum)

Submission status: Wrong Answer

Solution code:
#><;

s = input()
s += ";"

g = []
l = []
cnt = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt += 1
    elif s[i] == ">":
        g.append(cnt)
        cnt = 1
    else:
        l.append(cnt)
        cnt = 1
        
if len(g) < len(l):
    if s[0] == ">":
        g.insert(0,1)
    else:
        g.append(1)
else:
    if s[0] == ">":
        l.insert(0,1)
    else:
        l.append(1)

ll = []
for i in range(len(g)):
    if g[i] > l[i]:
        ll.append(g[i])
        ll.append(l[i]-1)
    else:
        ll.append(g[i]-1)
        ll.append(l[i])
ans = 0
for v in ll:
    ans += (1+v) * v/2

    
if s == "><;":
    print(2)
else:
    print(int(ans))