Problem:


Score : 300 points

Problem Statement

Given is a string S of length N-1.
Each character in S is < or >.

A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \leq i \leq N-1):

If S_i= <: a_i<a_{i+1}

If S_i= >: a_i>a_{i+1}

Find the minimum possible sum of the elements of a good sequence of N non-negative integers.

Constraints

2 \leq N \leq 5 \times 10^5

S is a string of length N-1 consisting of < and >.

Input

Input is given from Standard Input in the following format:

S

Output

Find the minimum possible sum of the elements of a good sequence of N non-negative integers.

Sample Input 1

<>>

Sample Output 1

3

a=(0,2,1,0) is a good sequence whose sum is 3.
There is no good sequence whose sum is less than 3.

Sample Input 2

<>>><<><<<<<>>><

Sample Output 2

28



Sample input:
<>>


Sample output:
3

Submission status: Wrong Answer

Solution code:
s = input().strip()
#  < > > > < < > < < < < < > > > <
# 0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1

#  <p> > > < <p> < < < < <p> > > <
# 0 1     0 1 2 1 0 1 2 3 4 5     0  1 
20
#  < > > > < < > < < < < < > > > <
#   3 2  1      1           3 2 1 0   

buf = s[0]
count = 0
popa  = []
suma = 0
for i in s:
  if i=="<":
    count+=1
    suma += count
  elif i==">" and buf=="<":
    popa.append(count)
    suma -= count
    count = 0
  buf = i

buf = s[-1]
count = 0
dupa  = []
for i in s[::-1]:
  if i==">":
    count+=1
    suma += count
  elif i=="<" and buf==">":
    dupa.append(count)
    suma -= count
    count = 0
  buf = i
for i,j in zip(dupa,popa):
  suma+=max(i,j)
print(suma)
# print(sum(map(int,"0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1".split())))

Submission status: Wrong Answer

Solution code:
s = input().strip()
#  < > > > < < > < < < < < > > > <
# 0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1

#  <p> > > < <p> < < < < <p> > > <
# 0 1     0 1 2 1 0 1 2 3 4 5     0  1 
20
#  < > > > < < > < < < < < > > > <
#   3 2  1      1           3 2 1 0   

buf = s[0]
count = 0
popa  = []
suma = 0
for i in s:
  if i=="<":
    count+=1
    suma += count
  elif i==">" and buf=="<":
    popa.append(count)
    suma -= count
    count = 0
  buf = i

buf = s[-1]
count = 0
dupa  = []
for i in s[::-1]:
  if i==">":
    count+=1
    suma += count
  elif i=="<" and buf==">":
    dupa.append(count)
    suma -= count
    count = 0
  buf = i
for i,j in zip(dupa,popa):
  suma+=max(i,j)
# print(sum(map(int,"0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1".split())))

Submission status: Wrong Answer

Solution code:
S = [1 if val == '<' else -1 for val in input()]
index = 0
ans = 0
cnt = 0
tmp = 0
p_cnt = 0

while True:
    while S[index + cnt] == 1:
        tmp += cnt + 1
        if index + cnt + 1 == len(S):
            print(ans+tmp)
            exit()
        cnt += 1

    ans += tmp  
    p_cnt = cnt
    index += cnt
    tmp = 0
    cnt = 0

    while S[index + cnt] == -1:
        tmp += cnt + 1
        if index + cnt + 1 == len(S):
            ans += tmp
            if cnt < p_cnt:
                ans = ans - cnt
            else :
                ans = ans - p_cnt
            print(ans)
            exit()
        cnt += 1

    ans += tmp
    if cnt < p_cnt:
        ans = ans - cnt
    else :
        ans = ans - p_cnt
    index += cnt
    tmp = 0
    cnt = 0

Submission status: Wrong Answer

Solution code:
S = [1 if val == '<' else -1 for val in input()]
print(S)
index = 0
ans = 0
cnt = 0
tmp = 0
p_cnt = 0

while True:
    while S[index + cnt] == 1:
        tmp += cnt + 1
        if index + cnt + 1 == len(S):
            print(ans+tmp)
            exit()
        cnt += 1

    print(tmp)
    ans += tmp  
    p_cnt = cnt
    index += cnt
    tmp = 0
    cnt = 0

    while S[index + cnt] == -1:
        tmp += cnt + 1
        if index + cnt + 1 == len(S):
            ans += tmp
            if cnt < p_cnt:
                ans = ans - cnt
            else :
                ans = ans - p_cnt
            print(ans)
            exit()
        cnt += 1

    print(tmp)
    ans += tmp
    if cnt < p_cnt:
        ans = ans - cnt
    else :
        ans = ans - p_cnt
    index += cnt
    tmp = 0
    cnt = 0

Submission status: Wrong Answer

Solution code:
import sys
S = input()
l = len(S)
i = 0
x = 0
ans = 0
y = 0
#t = ''
while True:
    if S[i] == '<':
        x = 0
        if i+1 < l and S[i+1] == '<':
            x = 1
        while S[i] == '<':
            ans += x
            #t += str(x)
            x += 1
            i += 1
            if i >= l:
                print(ans+1)
                #print(t)
                sys.exit(0)
    if S[i] == '>':
        if i + 1 < l and S[i+1] == '>':
            if i-1 != 0:
                y -= 1
                while S[i] == '>':
                    y += 1
                    i += 1
                    if i >= l:
                        break
                while y != 0:
                    #t += str(y)
                    ans += y
                    y -= 1
                i-=1
            else:
                while S[i] == '>':
                    y += 1
                    i += 1
                    if i >= l:
                        break
                while y != 0:
                    #t += str(y)
                    ans += y
                    y -= 1
                i-=1
        i += 1
    if i >= l:
        print(ans)
        sys.exit(0)

Submission status: Wrong Answer

Solution code:
s = input()
big = 0
small = 0
n = 0
big2 =0
for i in range(len(s)):
  if s[i]=='<':
    big += 1
    n += big
    small =0
    big2 = big
  else:
    small += 1
    n += small
    if small<=big2:
      n-=1
      big =0
  print(n)

Submission status: Wrong Answer

Solution code:
import re
s = input()
ans = [-1] * (len(s) + 1)
if s[0] == '<':
    ans[0] = 0
    diff = 1
    while (0 <= diff < len(s)) & (s[diff - 1] == '<'):
        ans[diff] = max(ans[diff], ans[diff - 1] + 1)
        diff += 1
        
if s[len(s) - 1] == '>':
    t = len(s)
    ans[t] = 0
    diff = -1
    while (0 <= t + diff < len(s)) & (s[t + diff] == '>'):
        ans[t + diff] = max(ans[t + diff], ans[t + diff + 1] + 1)
        diff -= 1

match = []
for i in range(len(s)):
    if s[i:i+2] == '><':
        match.append(i)

for i in match:
    ans[i + 1] = 0
    diff = 1
    while (0 <= i + 1 - diff < len(s)):
        if s[i - diff + 1] == '<':
            break
        ans[i + 1 - diff] = max(ans[i + 1 - diff], ans[i - diff + 2] + 1)
        diff += 1
    diff = 1
    while (0 <= i + diff < len(s)):
        if s[i + diff] == '>':
            break
        ans[i + 1 + diff] = max(ans[i + 1 + diff], ans[i + diff] + 1)
        diff += 1
print(sum(ans))

Submission status: Wrong Answer

Solution code:
S = str(input())

N = len(S) + 1

ans = [0] * N


for i in range(N):
    k = 0
    right = 0
    while(i + k < N-1 and S[i+k] == '>'):
        right += 1
        k += 1

    j = 0
    left = 0
    while (N-1 > i - j - 1 > 0 and S[i - j - 1] == '<'):
        left += 1
        j += 1


    ans[i] = max(right, left)

#print(ans)
print(sum(ans))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

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

i = 0
ind = 0
flag = 0
if S[0] == '>':
    while S[ind] == '>':
        ind += 1
        if ind >= N:
            flag = 1
            break
    num = ind
    for i in range(ind+1):
        A[i] = num
        num -= 1
i = ind
if flag:
    print(sum(A))
    exit()
if S.count('<') == N:
    print(N*(N+1)//2)
    exit()
if S == '><':
    print(2)
    exit()
while True:
    if S[i] == '<' and S[i+1] == '>':
        cnt = 0
        while True:
            cnt += 1
            if i+1+cnt > N-1 or S[i+1+cnt] == '<':
                break
        #print(i, cnt)
        if i+1-ind >= cnt+1:
            num = 1
            for j in range(ind+1, i+2):
                A[j] = num
                num += 1
            num = 0
            for j in reversed(range(i+2, i+cnt+2)):
                A[j] = num
                num += 1
        else:
            num = 1
            for j in range(ind+1, i+1):
                A[j] = num
                num += 1
            num = 0
            for j in reversed(range(i+1, i+cnt+2)):
                A[j] = num
                num += 1
        ind = i+cnt+1
        i += cnt
        #print(A)
    else:
        A[i+1] = A[i]
    i += 1
    if i >= N-1:
        if i == N-1:
            A[i+1] = 1
        break

#print(A)
print(sum(A))

Submission status: Wrong Answer

Solution code:
s=input()
cnt=1
l=[]
for i in range(len(s)-1):
    if s[i]=="<":
        if s[i+1]=="<":
            cnt+=1
        else:
            l.append(cnt)
            cnt=-1
    else:
        if s[i+1]==">":
            cnt-=1
        else:
            l.append(cnt)
            cnt=1
l.append(cnt)
ans=0
for i in range(len(l)-1):
    if l[i]>0 and l[i+1]<0:
        a=abs(l[i])
        b=abs(l[i+1])
        ans+=max(a,b)
        ans+=(a-1)*a//2+(b-1)*b//2
if l[0]<0:
    ans+=(abs(l[0])+1)*abs(l[0])//2
if l[-1]>0:
    ans+=(l[-1]+1)*l[-1]//2
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
N = len(S)
#print('S',S)

dammy1=[0]*(N+1)
A=0
for i in range(1,N+1):
    if S[i-1]=='<':
        A+=1
        dammy1[i]=A
    elif S[i-1]=='>':
        A=0
        dammy1[i]=A

dammy2=[0]*(N+1)
B=0
for i in range(1,N):
    if S[-i]=='>':
        B+=1
        dammy2[-(i+1)]=B
    elif S[i]=='<':
        B=0
        dammy2[-(i+1)]=B

#print('dammy1', dammy1)
#print('dammy2', dammy2)

out=[0]*(N+1)
for i in range(N+1):
    out[i] = max(dammy1[i], dammy2[i])

#print('out', out)
print(sum(out))

Submission status: Wrong Answer

Solution code:
S = input()
s = len(S)
ans_list = list()

for i in range(s):
  n = i
  k1 = 0
  k = 0
  j = -1
  if S[i] == ">" and S[i-1] == "<":
    while 0 < n and S[i -1] == S[n -1]:
      k += 1
      n -= 1
    n = i
    while n <= s - 1 and S[i] == S[n]:
      k1 += 1
      n += 1
    k = max(k,k1)
      
  elif S[i] == ">":
    while n <= s - 1 and S[i] == S[n]:
      k += 1
      n += 1
  else:
    while 0 < n and S[i] == S[n]:
      j += 1
      n -= 1
  ans_list.append(max(k,j))
if S[-1] == ">":
  print(sum(ans_list))
elif S[-1] == "<" and S[-1] == "<":
  print(sum(ans_list) +ans_list[-1] +1)
else:
  print(sum(ans_list) +1)

Submission status: Wrong Answer

Solution code:
S = input()
s = len(S)
ans_list = list()

for i in range(s):
  n = i
  k1 = 0
  k = 0
  j = -1
  if S[i] == ">" and S[i-1] == "<":
    while 0 < n and S[i -1] == S[n -1]:
      k += 1
      n -= 1
    n = i
    while n <= s - 1 and S[i] == S[n]:
      k1 += 1
      n += 1
    k = max(k,k1)
      
  elif S[i] == ">":
    while n <= s - 1 and S[i] == S[n]:
      k += 1
      n += 1
  else:
    while 0 < n and S[i] == S[n]:
      j += 1
      n -= 1
  ans_list.append(max(k,j))
print(ans_list)
if S[-1] == ">":
  print(sum(ans_list))
elif S[-1] == "<" and S[-1] == "<":
  print(sum(ans_list) +ans_list[-1] +1)
else:
  print(sum(ans_list) +1)

Submission status: Wrong Answer

Solution code:
S = input()
s = len(S)
ans_list = list()

for i in range(s):
  n = i
  k1 = 0
  k = 0
  j = -1
  if S[i] == ">" and S[i-1] == "<":
    while 0 < n and S[i -1] == S[n -1]:
      k += 1
      n -= 1
    n = i
    while n <= s - 1 and S[i] == S[n]:
      k1 += 1
      n += 1
    k = max(k,k1)
      
  elif S[i] == ">":
    while n <= s - 1 and S[i] == S[n]:
      k += 1
      n += 1
  else:
    while 0 < n and S[i] == S[n]:
      j += 1
      n -= 1
  ans_list.append(max(k,j))
print(ans_list)
if S[-1] == ">":
  print(sum(ans_list))
else:
  print(sum(ans_list) +1)

Submission status: Wrong Answer

Solution code:
S = input()
# N, K = [int(_) for _ in input().split()]
count = 1
S2 = []
for i in range(len(S)):
    if i < len(S)-1 and S[i] == S[i+1]:
        count += 1
    else:
        if S[i] == '<':
            S2.append(['<', count])
        else:
            S2.append(['>', count])
        count = 1

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

Submission status: Wrong Answer

Solution code:
S=input()
con=0
ans=0
for s in S:
  con=(con+1)*(s=="<")
  ans+=con
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
N = len(S)+1
cnt = [0] * N
j = 0
k = 0

for i in range(N-2):
    if S[i] == S[i+1]:
        k += 1
    
    else:
        k += 1
        cnt[j] = k
        j += 1
        k = 0

if S[N-2] == S[N-3]:
    cnt[j] = k + 1
else:
    cnt[j] = 1

print(cnt)
ans = 0
if S[0] == "<":
    st = 0
else:
    ans += cnt[0]*(cnt[0]+1)//2
    st = 1

for k in range(st,N,2):
    if cnt[k] != 0:
        m = min(cnt[k],cnt[k+1])
        M = max(cnt[k],cnt[k+1])
        ans += m*(m-1)//2 + M*(M+1)//2 
    else:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
N = len(S)+1
cnt = [0] * N
j = 0
k = 0

for i in range(N-2):
    if S[i] == S[i+1]:
        k += 1
    
    else:
        k += 1
        cnt[j] = k
        j += 1
        k = 0

if S[N-2] == S[N-3]:
    cnt[j] = k + 1
else:
    cnt[j] = 1

ans = 0
if S[0] == "<":
    st = 0
else:
    ans += cnt[0]*(cnt[0]-1)//2
    st = 1

for k in range(st,N,2):
    if cnt[k] != 0:
        m = min(cnt[k],cnt[k+1])
        M = max(cnt[k],cnt[k+1])
        ans += m*(m-1)//2 + M*(M+1)//2 
    else:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
left = 0
cou = 0
l = [0 for i in range(len(s)+1)]
for i in range(len(s)):
  s1 = s[i]
  a1 = l[i]
#  print(s1,l,cou)
  if s1=='<':
    l[i+1] = l[i]+1
    left = 0
  else:
    l[i+1] = l[i]-1
    left += 1
    if l[i+1]>=0:
      l[i+1] = 0
      left = 0
    else:
      l[i+1] =0
      cou += left
print(cou+sum(l))

Submission status: Wrong Answer

Solution code:
s = list(input())
data = [0] * (len(s) + 1)
for i in range(len(s)):
    if s[i] == "<":
        data[i + 1] = data[i] + 1

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

Submission status: Wrong Answer

Solution code:

import math

def main():
    s = str(input())
    first = s[0]
    cnt_l = []
    tmp_cnt = 1
    prev_s = first
    for curr_s in s[1:]:
        if prev_s != curr_s:
            cnt_l.append(tmp_cnt)
            tmp_cnt = 1
        else:
            tmp_cnt+=1
        prev_s = curr_s
    cnt_l.append(tmp_cnt)

    ans_l = []
    last_num = 0
    if first == '>':
        down_cnt = cnt_l[0]
        for d in range(down_cnt):
            ans_l.append(down_cnt-d)
        cnt_l = cnt_l[1:]

    # if first == '<':
    # print(cnt_l)
    ans_l.append(0)
    last_num = 0
    for i in range(math.ceil(len(cnt_l)/2)):
        # print('i',i)
        up_cnt = cnt_l[i*2]
        if i*2+1 >= len(cnt_l):
            down_cnt = 0
        else:
            down_cnt = cnt_l[i*2+1]
        # print(up_cnt,down_cnt)
        # print()
        for u in range(up_cnt):
            if u != up_cnt-1:
                last_num+=1
                ans_l.append(last_num)
            else:
                last_num = max(last_num+1, down_cnt)
                ans_l.append(last_num)
        for d in range(down_cnt):
            if d==0:
                if last_num > down_cnt:
                    last_num = down_cnt-1
                else:
                    last_num-=1
                ans_l.append(last_num)
            else:
                last_num-=1
                ans_l.append(last_num)

    print(ans_l)
    print(sum(ans_l))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

import math

def main():
    s = str(input())
    first = s[0]
    cnt_l = []
    tmp_cnt = 1
    prev_s = first
    for curr_s in s[1:]:
        if prev_s != curr_s:
            cnt_l.append(tmp_cnt)
            tmp_cnt = 1
        else:
            tmp_cnt+=1
        prev_s = curr_s
    cnt_l.append(tmp_cnt)

    ans_l = []
    last_num = 0
    if first == '>':
        down_cnt = cnt_l[0]
        for d in range(down_cnt):
            ans_l.append(down_cnt-1-d)
        cnt_l = cnt_l[1:]

    # if first == '<':
    # print(cnt_l)
    ans_l.append(0)
    last_num = 0
    for i in range(math.ceil(len(cnt_l)/2)):
        # print('i',i)
        up_cnt = cnt_l[i*2]
        if i*2+1 >= len(cnt_l):
            down_cnt = 0
        else:
            down_cnt = cnt_l[i*2+1]
        # print(up_cnt,down_cnt)
        # print()
        for u in range(up_cnt):
            if u != up_cnt-1:
                last_num+=1
                ans_l.append(last_num)
            else:
                last_num = max(last_num+1, down_cnt)
                ans_l.append(last_num)
        for d in range(down_cnt):
            if d==0:
                if last_num > down_cnt:
                    last_num = down_cnt-1
                else:
                    last_num-=1
                ans_l.append(last_num)
            else:
                last_num-=1
                ans_l.append(last_num)

    # print(ans_l)
    print(sum(ans_l))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)


def solve(s):
    start_up = s[0] == "<"
    curr_up = start_up
    counts = [1]
    for c in s[1:]:
        if curr_up == (c == "<"):
            counts[-1] += 1
        else:
            curr_up = not curr_up
            counts.append(1)

    result = counts[0]*(counts[0]-1)//2
    curr_up = start_up
    for i in range(1, len(counts)):
        if curr_up:
            result += max(counts[i-1], counts[i])
        result += counts[i]*(counts[i]-1)//2
        curr_up = not curr_up
    if curr_up:
        result += counts[-1]

    return result


if __name__ == "__main__":
    s = str_in()
    out(solve(s))

Submission status: Wrong Answer

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

ans = 0

cnt0 = 0
if S[0] == ">":
    cnt0 += 1
    j = 1
    while j <= len(S)-1 and S[j] == ">":
        cnt0 += 1
        j += 1
ans += cnt0*(cnt0+1)//2
print(cnt0)

for i in range(1, N-1):
    if S[i-1] == "<" and S[i] == ">":
        j = i-1
        k = i+1
        cnt1 = 0
        cnt2 = 0
        if S[i-1] == "<" and i >= 0:
            while j >= 0 and S[j] == S[i-1] :
                cnt1 += 1 
                j -= 1
        if S[i] == ">":
            while k <= N-1 and S[i] == S[k-1]:
                cnt2 += 1
                k += 1 
        ans += max(cnt1, cnt2)*(max(cnt1, cnt2)+1)//2
        ans += (min(cnt1, cnt2)-1)*(min(cnt1, cnt2))//2
        print(cnt1, cnt2)

cntn = 0
if S[-1] == "<":
    cntn += 1
    j = -2
    while j >= -len(S) and S[j] == "<":
        cntn += 1
        j -= 1
ans += cntn*(cntn+1)//2
print(cntn)

print(ans)

Submission status: Wrong Answer

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

ans = 0

cnt0 = 0
if S[0] == ">":
    cnt0 += 1
    j = 1
    while j <= len(S)-1 and S[j] == ">":
        cnt0 += 1
        j += 1
ans += cnt0*(cnt0+1)//2

for i in range(1, N-1):
    if S[i-1] == "<" and S[i] == ">":
        j = i-1
        k = i+1
        cnt1 = 0
        cnt2 = 0
        if S[i-1] == "<" and i >= 0:
            while j >= 0 and S[j] == S[i-1] :
                cnt1 += 1 
                j -= 1
        if S[i] == ">":
            while k <= N-1 and S[i] == S[k-1]:
                cnt2 += 1
                k += 1 
        ans += max(cnt1, cnt2)*(max(cnt1, cnt2)+1)//2

cntn = 0
if S[-1] == "<":
    cntn += 1
    j = -2
    while j >= -len(S) and S[j] == "<":
        cntn += 1
        j -= 1
ans += cntn*(cntn+1)//2

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input()
t = 0
ans = 0
f = a[0]
if f == '>':ans+=1
elif f == '<':t = 0
for i in a[1:]:
    # print(f,i)
    if f == '>' and i == '<':
        t = 0
    elif f == '<' and i == '>':
        t += 1
        ans +=t
        if t != 1 : t = 0
    else:
        t += 1
        ans+=t
    f = i
    # print(t,ans)
if f == '>':t=1
print(ans+(f == '<'))

Submission status: Wrong Answer

Solution code:
S = list(map(str, input()))
N = len(S)+1
List = [0]*N
rightcount = 0
leftcount = 0

if S[0] == "<":
    leftcount+=1
else:
    rightcount+=1

for i in range(1, N-1):
    if S[i] == "<":
        leftcount+=1
        if S[i-1] == "<":
            List[i] = List[i-1]+1
        elif S[i-1] == ">":
            for j in range(rightcount):
                List[i-j] = j
            if List[i-rightcount]<=List[i-rightcount+1]:
                List[i-rightcount] = List[i-rightcount+1] + 1
            rightcount = 0


    if S[i] == ">":
        rightcount+=1
        if S[i-1] =="<":
            for j in range(leftcount+1):
                List[i-j] = leftcount - j
            leftcount = 0

if S[N-2] == "<":
    List[N-1] = List[N-2] + 1
else:
    for j in range(rightcount):
        List[N-1-j] = j
    if List[N-1-rightcount]<=List[N-1-rightcount+1]:
        List[N-1-rightcount] = List[N-1-rightcount+1] + 1

print(List)
print(sum(List))

Submission status: Wrong Answer

Solution code:
S = list(map(str, input()))
N = len(S)+1
List = [0]*N
rightcount = 0
leftcount = 0

if S[0] == "<":
    leftcount+=1
else:
    rightcount+=1

for i in range(1, N-1):
    if S[i] == "<":
        leftcount+=1
        if S[i-1] == ">":
            for j in range(rightcount):
                List[i-j] = j
            if List[i-rightcount]<=List[i-rightcount+1]:
                List[i-rightcount] = List[i-rightcount+1] + 1
            rightcount = 0


    if S[i] == ">":
        rightcount+=1
        if S[i-1] =="<":
            for j in range(leftcount+1):
                List[i-j] = leftcount - j
            leftcount = 0

if S[N-2] == "<":
    List[N-1] = List[N-2] + 1
else:
    for j in range(rightcount):
        List[N-1-j] = j
    if List[N-1-rightcount]<=List[N-1-rightcount+1]:
        List[N-1-rightcount] = List[N-1-rightcount+1] + 1

print(sum(List))

Submission status: Wrong Answer

Solution code:
S = list(map(str, input()))
N = len(S)+1
List = [0]*N
rightcount = 0
leftcount = 0

if S[0] == "<":
    leftcount+=1
else:
    rightcount+=1

for i in range(1, N-1):
    if S[i] == "<":
        leftcount+=1
        if S[i-1] == ">":
            for j in range(rightcount):
                List[i-j] = j
            if List[i-rightcount]<=List[i-rightcount+1]:
                List[i-rightcount] = List[i-rightcount+1] + 1
            rightcount = 0


    if S[i] == ">":
        rightcount+=1
        if S[i-1] =="<":
            for j in range(leftcount+1):
                List[i-j] = leftcount - j
            leftcount = 0

if S[N-2] == "<":
    List[N-1] = 1
else:
    for j in range(rightcount):
        List[N-1-j] = j
    if List[N-1-rightcount]<=List[N-1-rightcount+1]:
        List[N-1-rightcount] = List[N-1-rightcount+1] + 1

print(sum(List))

Submission status: Wrong Answer

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

i = 0
left = 0
right = 0
ans = 0
tmp = 1
while i < n-1:
	if i == n-2:
		if s[i] == '>':
			right += 1
			break
		else:
			left += 1
			break
	if s[i] == '<' and s[i+1] == '>':
		left += 1
		while True:
			if s[i+1+right] == '>':
				right += 1
				if i+1+right == n-1:
					break
			else:
				break
		if left >= right:
			ans += left * (left + 1) // 2 + (right - 1) * right // 2
		else:
			ans += right * (right + 1) // 2 + (left - 1) * left // 2
		i += right + 1
		left = 0
		right = 0
	elif s[i] == '<':
		left += 1
		i += 1
	else:
		right += 1
		i += 1

print(ans + left * (left + 1) // 2 + right * (right + 1) // 2 )

Submission status: Wrong Answer

Solution code:
def compute_score(sub):
    max_i = max(sub)
    min_i = min(sub)
    score = max_i * (max_i + 1) * (1 /2) + min_i * (min_i - 1) * (1/2)
    return score

S = input()
sub = [0, 0]
ans = 0
flag = False
for s in S:
    if s == '<' and flag:
        ans += compute_score(sub)
        sub = [0, 0]
        flag = False
    if s == '>':
        flag = True
    if s == '<':
        sub[0] += 1
    else:
        sub[1] += 1
ans += compute_score(sub)
print(ans)

Submission status: Wrong Answer

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

A = [0 for _ in range(n)]
for i in range(n - 1):
    prev = A[i]
    if S[i] == "<":
        A[i + 1] = max(A[i + 1], prev + 1)

for i in range(n - 2, 0, -1):
    prev = A[i + 1]
    if S[i] == ">":
        A[i] = max(A[i], prev + 1)

print(sum(A))

Submission status: Wrong Answer

Solution code:

def main():
    S = list(input())
    lenS = len(S)
    bfr = -1
    cnt = 0
    ans = []
    dwn = 0
    S.append('<')
    while cnt <= lenS:
        nxt = S[cnt]
        if nxt == '<' and dwn == 0:
            ans.append(max(0,bfr+1))
            bfr = max(0, bfr+1)
            cnt += 1
        elif nxt == '<' and dwn > 0:
            ans.append(max(bfr+1, dwn))
            ans += range(dwn-1, -1, -1)
            bfr = 0
            cnt += 1
            dwn = 0
        else:
            dwn += 1
            cnt += 1
    print(ans)
    print(sum(ans))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s=input()
SUM=0
p=0;q=0
b=0
h=s[0]
for i in range(len(s)):
    if s[i]==h and b==0:
        p+=1
    if s[i]!=h:
        q+=1
        b=1
    if (s[i]==h and b==1) or (i==len(s)-1):
        w1=max(p,q)
        w2=min(p,q)
        SUM+=(1+w1)*w1//2+w2*(w2-1)//2
        if (s[i]==h and b==1) and (i==len(s)-1):
            SUM+=1
        b=0
        p=1;q=0
        
print(SUM)

Submission status: Wrong Answer

Solution code:
s = input() #sys.stdin.readlineは最後が改行
n = len(s)

INF = float('inf')

a = [-INF]*(n+1)

for i in range(n):
    if i==0:
        if s[i] =='<':
            a[i]=0
        continue
    if i==n-1:
        if s[i] =='>':
            a[i+1]=0
        continue

    if s[i] =='>' and s[i+1]=='<':
        a[i+1]=0


def left(i):
    while True:
        if i ==0:
            break
        if s[i-1] == '>' and a[i-1] <=a[i]:
            a[i-1]=a[i]+1
        else:
            break
        i-=1

def right(i):
    while True:
        if i==n:
            break
        if s[i] == '<' and a[i]>=a[i+1]:
            a[i+1]=a[i]+1
        else:
            break
        i+=1

for i in range(n+1):
    if a[i] == 0:
        left(i)
        right(i)

print(sum(a))

Submission status: Wrong Answer

Solution code:
S = input()

tmp1 = [0 for _ in range(len(S)+1)]
tmp2 = [0 for _ in range(len(S)+1)]

for i in range(len(S)):
  if S[i] == '>':
    tmp1[i] = 1
  else:
    tmp2[i+1] = 1

for i in range(1, len(S)+1):
  if tmp1[-i-1] != 0:
    tmp1[-i-1] = tmp1[-i] + tmp1[-i-1]

for i in range(2, len(S)):
  if tmp2[i] != 0:
    tmp2[i] = tmp2[i] + tmp2[i-1]

ans = 0
for i in range(len(S)+1):
  ans += max(tmp1[i], tmp2[i])

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

tmp1 = [0 for _ in range(len(S)+1)]
tmp2 = [0 for _ in range(len(S)+1)]

for i in range(len(S)):
  if S[i] == '>':
    tmp1[i] = 1
  else:
    tmp2[i+1] = 1

for i in range(1, len(S)+1):
  if tmp1[-i-1] != 0:
    tmp1[-i-1] = tmp1[-i] + tmp1[-i-1]

for i in range(2, len(S)):
  if tmp2[i] != 0:
    tmp2[i] = tmp2[i] + tmp2[i-1]

ans = 0
for i in range(len(S)):
  ans += max(tmp1[i], tmp2[i])

print(ans+1)

Submission status: Wrong Answer

Solution code:
S = input()

tmp1 = [0 for _ in range(len(S)+1)]
tmp2 = [0 for _ in range(len(S)+1)]

for i in range(len(S)):
  if S[i] == '>':
    tmp1[i] = 1
  else:
    tmp2[i+1] = 1

for i in range(1, len(S)+1):
  if tmp1[-i-1] != 0:
    tmp1[-i-1] = tmp1[-i] + tmp1[-i-1]

for i in range(2, len(S)):
  if tmp2[i] != 0:
    tmp2[i] = tmp2[i] + tmp2[i-1]

ans = 0
for i in range(len(S)):
  ans += max(tmp1[i], tmp2[i])

print(ans)

Submission status: Wrong Answer

Solution code:
A = list(input())

ans = [0] * (len(A) + 1)
sp = 0


for i in range(len(A)):
    if i <= sp:
        continue
    if A[i] == '<':
        ans[i + 1] = ans[i] + 1
    else:
        sp = i
        while A[sp] == '>':
            if sp == (len(A)-1) or A[sp+1] == '<':
                break
            else:
                sp += 1

        if sp - i + 1 > ans[i]:
            for j in range(sp, i - 1, -1):
                ans[j] = ans[j + 1] + 1

        else:
            for j in range(sp, i, -1):
                ans[j] = ans[j + 1] + 1

print(sum(ans))

Submission status: Wrong Answer

Solution code:
S = list(input())
len_S = len(S)
a = [0]*(len_S+1)
for i, s in enumerate(S):
    if s == '<':
        a[i+1] = a[i]+1
for i, s in enumerate(S[::-1]):
    inv_i = len_S-1-i
    if s == '>':
        a[inv_i] = max(a[inv_i+1]+1, a[inv_i])
print(a)

Submission status: Wrong Answer

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

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

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

print(sum(a))
print(a)

Submission status: Wrong Answer

Solution code:
s=input()
rl=[]
ll=[]
c=0
for i in range(len(s)-1):
  c+=1
  if s[i]!=s[i+1]:
    if s[i]=='<':
      rl.append(c)
    else:
      ll.append(c)
    c=0
if s[len(s)-1]=='<':
  rl.append(c+1)
else:
  ll.append(c+1)

rn=len(rl)
ln=len(ll)
ans=0
if s[0]=='<':
  for i in range(ln):
    M=max(rl[i], ll[i])
    m=min(rl[i], ll[i])
    ans+=M*(M+1)//2+m*(m-1)//2
  if rn>ln:
    ans+=rl[-1]*(rl[-1]+1)//2
else:
  ans+=ll[0]*(ll[0]+1)//2
  for i in range(rn-1):
    M=max(rl[i], ll[i+1])
    m=min(rl[i], ll[i+1])
    ans+=M*(M+1)//2+m*(m-1)//2
  if rn==ln:
    ans+=rl[-1]*(rl[-1]+1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input().rstrip())
n=len(s)+1
from_left = [0]*n
from_right = [0]*n
ans=0
i=0
while i<n-1:
    if s[i] == '>':
        from_left[i] = 0
    else:
        from_left[i] = from_left[i-1]+1
    i+=1
i=n-2
while i>-1:
    if s[i] == '<':
        from_right[i]=0
    else:
        from_right[i] = from_right[i+1]+1
    i-=1
for i in range(0, n-1):
    ans+=max(from_left[i], from_right[i+1])
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
count1 = 0
count2 = 0
ans = 0
for i in s:
    if i == ">":
        count1 += 1
        ans += count1
        count2 = 0
    else:
        count2 += 1
        ans += count2
        count1  = 0
print(ans)