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 = str(input())
l = []
t = 0
for i in range(1,len(s)):
    if s[i] != s[i-1]:
        l.append(s[t:i])
        t = i
else:
    l.append(s[t:len(s)])


def calc(n):
    tmp = 0
    for i in range(1,n+1):
        tmp += i
    return tmp

left = 0
right = 0
ans = 0

for i,sg in enumerate(l):
    if sg[0]=='>':
        if len(sg)>=left:
            ans += calc(len(sg))
        else:
            ans += calc(len(sg)-1)
        right = len(sg)
    else:
        if len(sg)>=right or i!=len(l)-1:
            ans += calc(len(sg))
        else:
            ans += calc(len(sg)-1)
        left = len(sg)

print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
l = []

t = 0
for i in range(1,len(s)):
    if s[i] != s[i-1]:
        l.append(s[t:i])
        t = i
else:
    l.append(s[t:len(s)])

cnt = 0
ans = 0
prev = 0

def orthodox(n):
    tmp = 0
    for i in range(1,n+1):
        tmp += i
    return tmp


for i,sign in enumerate(l):
    if sign[0]=='>':
        if len(l[i-1]) >= len(l[i]):
            ans += orthodox(len(sign)-1)
        else:
            ans += orthodox(len(sign))
    elif sign[0]=='<':
        if i!=len(l)-1:
            if len(l[i]) < len(l[i+1]):
                ans += orthodox(len(sign)-1)
            else:
                ans += orthodox(len(sign))
        else:
            ans += orthodox(len(sign))

print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
l = []

t = 0
for i in range(1,len(s)):
    if s[i] != s[i-1]:
        l.append(s[t:i])
        t = i
else:
    l.append(s[t:len(s)])

cnt = 0
ans = 0
prev = 0

def orthodox(n):
    tmp = 0
    for i in range(1,n+1):
        tmp += i
    return tmp


for i,sign in enumerate(l):
    if sign[0]=='>':
        if len(l[i-1]) > len(l[i]):
            ans += orthodox(len(sign)-1)
        else:
            ans += orthodox(len(sign))
    elif sign[0]=='<':
        if i!=len(l)-1:
            if len(l[i]) < len(l[i+1]):
                ans += orthodox(len(sign)-1)
            else:
                ans += orthodox(len(sign))
        else:
            ans += orthodox(len(sign))
    
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
s = list(input())

A = []
top = 1
left = 0 if s[0] == '<' else 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        top += 1
    else:
        if left == 0:
            A.append(top)
            top = 1
            left = 1
        else:
            A.append(top)
            top = 1
            left = 0
A.append(top)
B = [0]
total = 0
for i in range(len(A)):
    if s[0] == '<':
        if i % 2 == 0:
            total += A[i]
        else:
            total -= A[i]
    else:
        if i % 2 == 0:
            total -= A[i]
        else:
            total += A[i]
    B.append(total)


B.append(10000000)

for i in range(len(B)):
    if B[i] < 0:
        B[i-1] += abs(B[i])
        B[i+1] += abs(B[i])
        B[i] = 0
    if B[i] > 0 and B[i-1] >= B[i] and B[i+1] >= B[i]:
        B[i-1] -= B[i]
        B[i+1] += B[i]
        B[i] = 0
B = B[:-1]

C = collections.Counter(B)
ans = 0
for i, j in zip(C.keys(), C.values()):
    ans += sum(a for a in range(i+1)) * j

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
s = list(input())

A = []
top = 1
left = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        top += 1
    else:
        if left == 0:
            A.append(top)
            top = 1
            left = 1
        else:
            A.append(top)
            top = 1
            left = 0
A.append(top)
B = [0]
total = 0
for i in range(len(A)):
    if i % 2 == 0:
        total += A[i]
    else:
        total -= A[i]
    B.append(total)

B.append(10000000)

for i in range(len(B)):
    if B[i] < 0:
        B[i-1] += abs(B[i])
        B[i+1] += abs(B[i])
        B[i] = 0
    if B[i] > 0 and B[i-1] >= B[i] and B[i+1] >= B[i]:
        B[i-1] -= B[i]
        B[i+1] += B[i]
        B[i] = 0
B = B[:-1]

C = collections.Counter(B)
ans = 0
for i, j in zip(C.keys(), C.values()):
    ans += sum(a for a in range(i+1)) * j

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
s = list(input())

A = []
top = 1
left = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        top += 1
    else:
        if left == 0:
            A.append(top)
            top = 1
            left = 1
        else:
            A.append(top)
            top = 1
            left = 0
A.append(top)
B = [0]
total = 0
for i in range(len(A)):
    if i % 2 == 0:
        total += A[i]
    else:
        total -= A[i]
    B.append(total)

B.append(0)

for i in range(len(B)):
    if B[i] < 0:
        B[i-1] += abs(B[i])
        B[i+1] += abs(B[i])
        B[i] = 0
    if B[i] > 0 and B[i-1] >= B[i] and B[i+1] >= B[i]:
        B[i-1] -= B[i]
        B[i+1] += B[i]
        B[i] = 0
B = B[:-1]

C = collections.Counter(B)
ans = 0
for i, j in zip(C.keys(), C.values()):
    ans += sum(a for a in range(i+1)) * j

print(ans)

Submission status: Wrong Answer

Solution code:
s = [*input()]


hugo = ["<", ">"]
base = s.index(s[0])

end = s.index(s[-1])#ダミー末尾
if end:
    s.append("<")
else:
    s.append(">")
    
a = [0]
b = [0,1]
for i in s[1:]:
    if i == hugo[base]:
        b.append(b[-1] + 1)
    else:
        if base:
            b.reverse()
        max_ = max(a[-1],b[0])
        b[0] = max_
        a.pop(-1)
        a.extend(b)
        if base:
            base = 0
        else:
            base = 1
        b = [0,1]    
print(sum(a))

Submission status: Wrong Answer

Solution code:
S = list(input())
before = 0
last_upper = -1
count = 0
answer = 0
for i, s in enumerate(S):
  print(answer, i, before, last_upper)
  if s == '<':
    if before < 0 and last_upper < i-1:
      answer += abs(before)*(i-last_upper)
      before = 0
    elif before > 0 and last_upper < i-1:
      answer -= before*(i-last_upper-1)
      before = 0
    before += 1
    answer += before
    last_upper = i
  else:
    before -= 1
    answer += before
print(answer, before, last_upper)
if before < 0:
  answer += abs(before)*(len(S)-last_upper)
elif before > 0:
  answer -= before*(len(S)-last_upper-1)
print(answer)

Submission status: Wrong Answer

Solution code:
S = list(input())
before = 0
last_upper = 0
count = 0
answer = 0
for i, s in enumerate(S):
  # print(answer, i, before, last_upper)
  if s == '<':
    if before < 0 and last_upper < i-1:
      answer += abs(before)*(i-last_upper)
      before = 0
    elif before > 0 and last_upper < i-1:
      answer -= before*(i-last_upper-1)
      before = 0
    before += 1
    answer += before
    last_upper = i
  else:
    before -= 1
    answer += before
# print(answer, last_upper)
if before < 0:
  answer += abs(before)*(len(S)-last_upper)
elif before > 0:
  answer -= before*(len(S)-last_upper-1)
print(answer)

Submission status: Wrong Answer

Solution code:
S = list(input())
before = ''
count = 0
answer = 0
for s in S:
  if s == before:
    count += 1
  else:
    before = s
    if count > 0:
      answer += (count+1)*(count+2)//2
      count = 0
if count > 0:
  answer += (count+1)*(count+2)//2
print(answer)

Submission status: Wrong Answer

Solution code:
S = list(input())
before = ''
count = 0
answer = 0
for s in S:
  if s == before:
    count += 1
  else:
    if count > 0:
      answer += (count+1)*(count+2)//2
      count = 0
if count > 0:
  answer += (count+1)*(count+2)//2
print(answer)

Submission status: Wrong Answer

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

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

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


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

Submission status: Wrong Answer

Solution code:
import collections

s = list(input())
s_count = collections.Counter(s)
max_s = max(s_count[">"], s_count["<"])
ans = sum(range(1, max_s + 1))
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

s = list(input())
s_count = collections.Counter(s)
max_s = min(s_count[">"], s_count["<"])
ans = sum(range(1, max_s + 1))
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
l = [s[0]]
for c in s[1:]:
    if c in l[-1]:
        l[-1] += c
    else:
        l.append(c)
a = []
now = 0
for c in l:
    if '<' in c:
        if now == 0:

            for i in range(len(c) + 1):
                a.append(i)
        else:
            for i in range(1, len(c) + 1):
                a.append(i)
        now = len(c)
    if '>' in c:
        if now <= len(c):
            if now != 0:
                a.pop()
            for i in reversed(range(len(c) + 1)):
                a.append(i)
        else:
            for i in reversed(range(len(c))):
                a.append(i)
        now = len(c) + 1
print((a))

Submission status: Wrong Answer

Solution code:
# A
S = input()
ans = [0] * (len(S)+1)
for i in range(len(S)):
  if S[i] == ">":
    ans[i+1] = max(ans[i+1],ans[i])
  
for i in range(len(S)-1,-1,-1):
  if S[i] == '>':
    ans[i] = max(ans[i],ans[i+1]+1)

print(sum(ans))

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] = max(a[i+1], a[i]+1)

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

print(sum(a))

Submission status: Wrong Answer

Solution code:
s = str(input())
a = [0]
l = len(s)
k = 1000000000000
for i in range(l):
  if(s[i]=="<"):
    a.append(a[-1]+1)
  else:
    a.append(a[-1]-1)
  k = min(a[-1],k)
ans = sum(a)
if(k<0):
  ans += (l+1)*abs(k)
print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
a = [0]
l = len(s)
k = 0
for i in range(l):
  if(s[i]=="<"):
    a.append(a[-1]+1)
  else:
    a.append(a[-1]-1)
  k = min(a[-1],k)
ans = sum(a)
if(k<0):
  ans += (l+1)*abs(k)
print(ans)

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]=max(A[i+1],A[i]+1)
    
for i in range(len(S)-2,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()

A=[0]*(len(S)+1)
for i in range(len(S)):
    if S[i]=='<':
        A[i+1]=max(A[i+1],A[i]+1)
    
for i in 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 = S.count('>')
ans = s*(s+1)/2

print(int(ans))

Submission status: Wrong Answer

Solution code:
n = input()[:-1]
while n[:len(n)//2] != n[len(n)//2:]:
  n = n[:-1]
print(len(n))

Submission status: Wrong Answer

Solution code:
s=input()

sl=len(s)+1
l=[0]*sl

for i in range(sl-1):
  if s[i]=="<":
    l[i+1]=l[i]+1
    
for i in range(sl-2,-1,-1):
  if s[i]==">":
    l[i]=max(l[i+1], l[i])
    
print(sum(l))

Submission status: Wrong Answer

Solution code:
S = list(input())
 
left = [0]*(len(S)+1)
 
right = [0]*(len(S)+1)
 
for i in range(len(S)):
    if S[i] == '<':
        left[i+1] += 1+left[i]
 
for i in range(len(S)-1,-1,-1):
    if S[i] == '>':
        right[i] = right[i+1]+1
 
ans = [0]*(len(S)+1)
for i in range(len(S)+1):
    ans[i] = max(left[i],right[i])
print(sum(ans)+1) #+1

Submission status: Wrong Answer

Solution code:
s = input()
ans = [0 for i in range(len(s)+1)]

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

print(sum(ans))

Submission status: Wrong Answer

Solution code:
s = input()

count = [0,0]
mode = ''
ans = 0

for i in range(len(s)):
    if i == len(s)-1:
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
        if max(count) == min(count):
            for j in range(max(count)+1):
                ans += 2*j
        else:
            for j in range(max(count)+1):
                ans += j
            for j in range(min(count)):
                ans += j
    elif count[0] != 0 and count[1] != 0 and s[i+1] != mode:
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
        if max(count) == min(count):
            for j in range(max(count)+1):
                ans += 2*j
        else:
            for j in range(max(count)+1):
                ans += j
            for j in range(min(count)):
                ans += j
        count[0] = 0
        count[1] = 0
        mode = ''
    elif count[0] == 0 and count[1] == 0:
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
    elif count[1] == 0 and s[i] == '<':
        count[0] += 1
    elif count[0] == 0 and s[i] == '>':
        count[1] += 1
    elif count[1] == 0 and s[i] == '>' and s[i+1] == '<':
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
        if max(count) == min(count):
            for j in range(max(count)+1):
                ans += 2*j
        else:
            for j in range(max(count)+1):
                ans += j
            for j in range(min(count)):
                ans += j
        count[0] = 0
        count[1] = 0
        mode = ''
    elif count[0] == 0 and s[i] == '<' and s[i+1] == '>':
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
        if max(count) == min(count):
            for j in range(max(count)+1):
                ans += 2*j
        else:
            for j in range(max(count)+1):
                ans += j
            for j in range(min(count)):
                ans += j
        count[0] = 0
        count[1] = 0
        mode = ''
    elif (count[1] == 0 or mode == '>') and s[i] == '>':
        count[1] += 1
        mode = '>'
    elif (count[0] == 0 or mode == '<') and s[i] == '<':
        count[0] += 1
        mode = '<'

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

count = [0,0]
mode = ''
ans = 0

for i in range(len(s)):
    if i == len(s)-1:
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
        for j in range(max(count)+1):
            ans += j
        for j in range(min(count)):
            ans += j
    elif count[0] != 0 and count[1] != 0 and s[i+1] != mode:
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
        for j in range(max(count)+1):
            ans += j
        for j in range(min(count)):
            ans += j
        count[0] = 0
        count[1] = 0
        mode = ''
    elif count[0] == 0 and count[1] == 0:
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
    elif count[1] == 0 and s[i] == '<':
        count[0] += 1
    elif count[0] == 0 and s[i] == '>':
        count[1] += 1
    elif count[1] == 0 and s[i] == '>' and s[i+1] == '<':
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
        for j in range(max(count)+1):
            ans += j
        for j in range(min(count)):
            ans += j
        count[0] = 0
        count[1] = 0
        mode = ''
    elif count[0] == 0 and s[i] == '<' and s[i+1] == '>':
        if s[i] == '<':
            count[0] += 1
        else:
            count[1] += 1
        for j in range(max(count)+1):
            ans += j
        for j in range(min(count)):
            ans += j
        count[0] = 0
        count[1] = 0
        mode = ''
    elif (count[1] == 0 or mode == '>') and s[i] == '>':
        count[1] += 1
        mode = '>'
    elif (count[0] == 0 or mode == '<') and s[i] == '<':
        count[0] += 1
        mode = '<'

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    examA()

def examA():
    S = SI()
    S = ">" + S + "<"
    N = len(S)
    A = [0]*(N)
    i = 0
    while(i<N-1):
        r = i + 1
        if S[i]==">" and S[i+1]=="<":
            A[i] = 0
            l = i-1
            cur = 0
            while(1<=l):
                cur += 1
                A[l] = max(A[l], cur)
                l -= 1
                if S[l+1]=="<":
                    #print("break",l,A)
                    break
            r = i+1
            cur = 0
            while(r<N):
                cur += 1
                A[r] = max(A[r], cur)
                r += 1
                if r==N or S[r]==">":
                    break
        #print(i,A)
        i = r
    #print(A)
    A[0] = 0; A[-1] = 0
    ans = sum(A)
    print(ans)
    return

def examB():
    H, W = LI()
    A = [SI()for _ in range(H)]
    C = defaultdict(int)
    for a in A:
        for s in a:
            C[s] += 1
    B = sorted(C.items())
    # print(B)
    flag_odd = not (H%2==1 and W%2==1)
    upper_2 = (H%2==1) * (W//2) + (W%2==1) * (H//2)
    for s,c in B:
        if c%2==1:
            if flag_odd:
                print("No")
                return
            flag_odd = True
        elif c%4==2:
            upper_2 -= 1
            if upper_2<0:
                print("No")
                return
    print("Yes")
    return

def examC():
    N, K = LI()
    P = LI()
    C = LI()

    if max(C)<0:
        print(max(C))
        return

    loop = [[0,0]for _ in range(N)]

    for i in range(N):
        checked = set()
        now = i
        score = 0
        while(now not in checked):
            checked.add(now)
            now = P[now]-1
            score += C[now]
        n = len(checked)
        for j in checked:
            loop[j] = [n,score]
    # print(loop)
    ans = 0
    for i in range(N):
        n,s = loop[i]
        score = 0
        if s>0:
            score += (K//n - 1) * s
        ans = max(ans,score)
        now = i
        for j in range(n + K%n):
            now = P[now] - 1
            score += C[now]
            ans = max(ans,score)

    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,alphabet_convert,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<31
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    main()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Wrong Answer

Solution code:
def main():
    examA()

def examA():
    S = SI()
    S = ">" + S + "<"
    N = len(S)
    A = [0]*N
    i = 0
    while(i<N-1):
        r = i + 1
        if S[i]==">" and S[i+1]=="<":
            A[i] = 0
            l = i-1
            cur = 0
            while(1<=l):
                cur += 1
                A[l] = max(A[l], cur)
                l -= 1
                if S[l+1]=="<":
                    #print("break",l,A)
                    break
            r = i+1
            cur = 0
            while(r<N-1):
                cur += 1
                A[r] = max(A[r], cur)
                r += 1
                if r==N-1:
                    break
                if S[r]==">":
                    break
        #print(i,A)
        i = r
    #print(A)
    A[0] = 0; A[-1] = 0
    ans = sum(A)
    print(ans)
    return

def examB():
    H, W = LI()
    A = [SI()for _ in range(H)]
    C = defaultdict(int)
    for a in A:
        for s in a:
            C[s] += 1
    B = sorted(C.items())
    # print(B)
    flag_odd = not (H%2==1 and W%2==1)
    upper_2 = (H%2==1) * (W//2) + (W%2==1) * (H//2)
    for s,c in B:
        if c%2==1:
            if flag_odd:
                print("No")
                return
            flag_odd = True
        elif c%4==2:
            upper_2 -= 1
            if upper_2<0:
                print("No")
                return
    print("Yes")
    return

def examC():
    N, K = LI()
    P = LI()
    C = LI()

    if max(C)<0:
        print(max(C))
        return

    loop = [[0,0]for _ in range(N)]

    for i in range(N):
        checked = set()
        now = i
        score = 0
        while(now not in checked):
            checked.add(now)
            now = P[now]-1
            score += C[now]
        n = len(checked)
        for j in checked:
            loop[j] = [n,score]
    # print(loop)
    ans = 0
    for i in range(N):
        n,s = loop[i]
        score = 0
        if s>0:
            score += (K//n - 1) * s
        ans = max(ans,score)
        now = i
        for j in range(n + K%n):
            now = P[now] - 1
            score += C[now]
            ans = max(ans,score)

    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,alphabet_convert,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<31
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    main()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
base = 0


a = [0] * (n + 1)

i = 0
while i < n and s[i] == '<':
    a[i + 1] = a[i] + 1
    i += 1

i = n - 1
while i > 0 and s[i] == '>':
    a[i] = max(a[i], a[i + 1] + 1)
    i -= 1

for i in range(n - 1):
    if s[i] == '>' and s[i + 1] == '<':
        j = i
        while j > 0 and s[j] == '>':
            a[j - 1] = max(a[j - 1], a[j] + 1)
            j -= 1
        j = i + 1
        while j < n and s[j] == '<':
            a[j] = max(a[j], a[j - 1] + 1)
            j += 1

print(sum(a))

Submission status: Wrong Answer

Solution code:
s = input()
s += 'a'
cnts = []
prev = s[0]
cnt = 1
for i,si in enumerate(s[1:]):
    if prev == si:
        cnt += 1
    else:
        cnts.append(cnt)
        cnt = 1
    prev = si


ans = 0
c_num = 0
if s[0] == '<':
    for i,c in enumerate(cnts):
        if i%2 == 0:
            ans += c*(c-1)//2
            c_num = c-1
        else:
            ans += c*(c-1)//2
            ans += max(c,c_num+1)
    if s[-2] == '<':
        ans += cnts[-1]
        # print(cnts[-1])
    print(ans)

if s[0] == '>':
    ans = cnts[0]*(cnts[0]-1)//2
    for i,c in enumerate(cnts[1:]):
        if i%2 == 0:
            ans += c*(c-1)//2
            c_num = c-1
        else:
            ans += c*(c-1)//2
            ans += max(c,c_num+1)
        
    if s[-2] == '<':
        ans += cnts[-1]
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input()
N = len(a)
c = []
temp = int(1)
ans = int(0)
for i in range(N):
    if i != N-1:
      if a[i] == a[i+1]:
        temp += 1
      else:
        c.append(temp)
        temp = 1
    else:
      if a[i-1] == a[i]:
        c.append(temp)
      else:
        c.append(1)

clen = len(c)
for i in range(clen):
  if i != clen-1:
      if a[0] == "<":
        if i % 2 == 0:
          ans = ans + c[i] * (c[i]-1) / 2 + max([c[i],c[i+1]])
        else:
          ans = ans + c[i] * (c[i]-1) / 2
      else:
        if i == 0:
            ans = ans + c[i] * (c[i]+1) / 2
        else:
            if i % 2 == 0:
              ans = ans + c[i] * (c[i]-1) / 2
            else:
              ans = ans + c[i] * (c[i]-1) / 2 + max([c[i],c[i+1]])

  else:
      if a[0] == "<":
        if i % 2 == 0:
          ans = ans + c[i] * (c[i]+1) / 2
        else:
          ans = ans + c[i] * (c[i]-1) / 2
      else:
        if i % 2 == 0:
          ans = ans + c[i] * (c[i]-1) / 2
        else:
          ans = ans + c[i] * (c[i]+1) / 2

print(int(ans))

Submission status: Wrong Answer

Solution code:
a = input()
N = len(a)
c = []
temp = int(1)
ans = int(0)
for i in range(N):
    if i != N-1:
      if a[i] == a[i+1]:
        temp += 1
      else:
        c.append(temp)
        temp = 1
    else:
      if a[i-1] == a[i]:
        c.append(temp)
      else:
        c.append(1)

clen = len(c)
for i in range(clen):
  if i != clen-1:
      if a[0] == "<":
        if i % 2 == 0:
          ans = ans + c[i] * (c[i]-1) / 2 + max([c[i],c[i+1]])
        else:
          ans = ans + c[i] * (c[i]-1) / 2
      else:
        if i % 2 == 0:
          ans = ans + c[i] * (c[i]-1) / 2
        else:
          ans = ans + c[i] * (c[i]-1) / 2 + max([c[i],c[i+1]])

  else:
      if a[0] == "<":
        if i % 2 == 0:
          ans = ans + c[i] * (c[i]+1) / 2
        else:
          ans = ans + c[i] * (c[i]-1) / 2
      else:
        if i % 2 == 0:
          ans = ans + c[i] * (c[i]-1) / 2
        else:
          ans = ans + c[i] * (c[i]+1) / 2

print(int(ans))

Submission status: Wrong Answer

Solution code:
s = list(input())
n = []

if s[0] == '>' and s[len(s) - 1] == '>':
    n.append(1)
cnt = 1
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        cnt += 1
    else:
        n.append(cnt)
        cnt = 1
n.append(cnt)
if s[0] == '<' and s[len(s) - 1] == '<':
    n.append(1)

ans = 0
for i in range(0, len(n) - 1, 2):
    lar = max(n[i], n[i + 1])
    smo = min(n[i], n[i + 1])
    ans += (1 + lar) * lar // 2
    ans += (1 + smo - 1) * (smo - 1) // 2

print(ans)

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] = max(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_new = S.replace('><', '>,<').replace('<>', '<,>').split(',')
num = []
for i in S_new:
    if '<' in i:
        N = i.count('<')
        num.append((N+1)*N/2)
    else:
        N = i.count('>')
        num.append((N+1)*N/2)
        
result = 0
if '<' in S_new[0]:
    for i in range(len(S_new)//2):
        result += num[2*i]+num[2*i+1]-min(len(S_new[2*i]), len(S_new[2*i+1]))
    if len(S_new)%2 == 0:
        pass
    else:
        result += num[-1]
else:
    result += num[0]
    if len(S_new)%2 == 0:
        result += num[-1]
        for i in range(len(S_new)//2-1):
            result += num[2*i]+num[2*i+1]-min(len(S_new[2*i]), len(S_new[2*i+1]))
    else:
        for i in range(len(S_new)//2):
            result += num[2*i]+num[2*i+1]-min(len(S_new[2*i]), len(S_new[2*i+1]))
            
print(int(result))