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:
def f(x):
    return x*(x+1)//2


s = input()
ans = 0
if len(set(s)) == 1:
    ss = len(s)
    ans = ss*(ss+1)
    print(ans)
    exit()

ss = s.replace('><' , '> <')
lst = ss.split()

for l in lst:
    a = l.count('<')
    b = l.count('>')
    
    if a == 0:
        ans += f(b)
    elif b == 0:
        ans += f(a)
    else:
        mn = min(a,b)
        mx = max(a,b)
        ans += f(mx) + f(mn-1)
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
cs = 0
cd = 0
length = []
cha = []
test=[]
count = 1
sum = 0
for i in s:
  test.append(i)

for i in range(1,len(test)):
  if test[i-1] == test[i]:
    count = count + 1
  else:
    cha.append(test[i-1])
    length.append(count)
    count = 1
  if i == len(test) - 1 :
    cha.append(test[i-1])
    length.append(count)
print(cha)
print(length)

for i in range(len(cha)):
  if cha[i] == '<' :
    sum +=  (1+length[i])*length[i]/2
  else:
    sum +=  (1+length[i])*length[i]/2
    if length[i-1] > length[i]:
      sum = sum + (length[i] - length[i-1]) + 1
print(int(sum))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
s = str(input())
 
s_length = len(s)
 
answer = 0
cnt = 0
t = 0
_t = 0
for i in range(s_length):
  if s[i] == '<':
    t += 1
    cnt = 0
    answer += t
  else:
    if t == 0:
      if _t <= cnt:
        t = 0
        cnt += 1
        answer += cnt 
      else:
        t = 0
        cnt += 1
        answer += cnt - 1
    else:
      _t = t
      t = 0
      answer += cnt * 1
      cnt += 1
      
print(answer)

Submission status: Wrong Answer

Solution code:
def solve(char):
    b = list(char)
    x = 1
    s = 0
    for i in range(len(b)-1):
      if b[i] == ">" and b[i+1] == "<":
        x = 0
      elif b[i] == "<" and b[i+1] == ">":
        s = s + x
        x = 1        
      else:
        x = x + 1
        s = s + x
        
    if b[0] == "<":
      start = 0
    else:
      start = x+1
          
    if b[len(b)-1] == "<":
      end = x+1
    else:
      end = 0
        
    s = s + start + end
        
    return s
    

if __name__ ==  "__main__":
    a = solve(input())
    print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    s = input()
    # s = '<>>><<><<<<<>>><'
    n_list = np.zeros(len(s)+1)

    for i in range(0, len(s)):
        if s[i] == '<':
            n_list[i+1] = n_list[i]+1
        else: # i = >
            j = i # jは左側の                           文字のインデックス
            k = 1                          
            for j in range(i, 0, -1):
                if s[j] == '<':
                    n_list[j+1] = n_list[j]+1
                    break
                n_list[j] = k                
                j-=1
                k+=1

        # print('i={} {}'.format(i, n_list))    
    if s[0] == '>':
        n_list[0] = n_list[1]+1
    # print(n_list)
    print(int(sum(n_list)))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

_s = input()


def chker(s):
    i = 1
    minisum = 0
    while len(s) >= i:
        if s[i - 1:i + 1] == '><':
            item = s[:i]
            l = item.count('<')
            r = len(item) - l
            l, r = (l, r) if l > r else (r, l)
            minisum += l * (l + 1) / 2 + r * (r - 1) / 2

            s = s[i:]
            i = 1
        else:
            i += 1

    item = s
    l = item.count('<')
    r = len(item) - l
    l, r = (l, r) if l > r else (r, l)
    minisum += l * (l + 1) / 2 + r * (r - 1) / 2

    print(int(minisum))


chker(_s)

Submission status: Wrong Answer

Solution code:
moji = list(input())
listlist=[]
inlist=[]
result=0
if moji[0]=='>':
    inlist.append(2)
else:
    pass
for i in range(len(moji)-1):
    if moji[i] == '>' and moji[i+1]=='<':
        listlist.append(inlist)
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
        inlist=[]
    elif moji[i] == '>' and moji[i+1]=='>':
            inlist.append(1)
    elif moji[i] == '<' and moji[i+1]=='<':
            inlist.append(2)
    elif moji[i] == '<' and moji[i+1]=='>':
            inlist.append(3)
if moji[len(moji)-2] == '>' and moji[len(moji)-1]=='<':
    result +=1
elif moji[len(moji)-2] == '>' and moji[len(moji)-1]=='>':
    result += 1 + max([inlist.count(1),inlist.count(2)])
    for m in range(inlist.count(1)+1):
        result += m
    for n in range(inlist.count(2)+1):
        result += n
elif moji[i] == '<' and moji[i+1]=='<':
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
elif moji[i] == '<' and moji[i+1]=='>':
    result += 1 + max([inlist.count(1),inlist.count(2)])
    for m in range(inlist.count(1)+1):
        result += m
    for n in range(inlist.count(2)+1):
        result += n
result

Submission status: Wrong Answer

Solution code:
s = list(input())
lens = len(s)
li = [0] * (len(s) + 1)
for itr, val in enumerate(s):
  if itr == 0:
    if val == "<":
      li[0] = 0
  else:
    if (s[itr - 1] == "<" and s[itr] == "<"):
      li[itr] = li[itr - 1] + 1
#    elif s[itr - 1] == ">" and s[itr] == "<":
#      li[itr] = 0
    if s[itr] == "<" and itr == lens - 1:
      li[itr + 1] = li[itr] + 1

for itr, val in enumerate(reversed(s)):
  if itr == 0:
    if val == ">":
      li[lens] = 0
  else:
    if s[lens - itr - 1] == ">" and s[lens - itr] == ">":
      li[lens - itr] = li[lens - itr + 1] + 1
    if s[0] == ">":
      li[0] = li[1] + 1
      
for itr, val in enumerate(s):
  if itr > 0:
    if s[itr - 1] == "<" and s[itr] == ">":
      li[itr] = max(li[itr - 1],li[itr + 1]) + 1 

print(sum(li))

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    #s = input()
    s = '>>><>>><<><<<<<>>><'
    n_list = np.zeros(len(s)+1)

    for i in range(0, len(s)):
        if s[i] == '<':
            n_list[i+1] = n_list[i]+1
        else: # i = >
            j = i # jは左側の                           文字のインデックス
            k = 1                          
            for j in range(i, 0, -1):
                if s[j] == '<':
                    n_list[j+1] = n_list[j]+1
                    break
                n_list[j] = k                
                j-=1
                k+=1

        # print('i={} {}'.format(i, n_list))    
    if s[0] == '>':
        n_list[0] = n_list[1]+1
    # print(n_list)
    print(int(sum(n_list)))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    #s = input()
    s = '>>><>>><<><<<<<>>><'
    n_list = np.zeros(len(s)+1)

    for i in range(0, len(s)):
        if s[i] == '<':
            n_list[i+1] = n_list[i]+1
        else: # i = >
            j = i # jは左側の                           文字のインデックス
            k = 1                          
            for j in range(i, 0, -1):
                if s[j] == '<':
                    n_list[j+1] = n_list[j]+1
                    break
                n_list[j] = k                
                j-=1
                k+=1

        # print('i={} {}'.format(i, n_list))    
    if s[0] == '>':
        n_list[0] = n_list[1]+1
    # print(n_list)
    print(int(sum(n_list)))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s = list(str(input()))

ans = []
_x = s[0]
l= 1
for x in s[1:]:
    if x == _x:
        l += 1
    else:
        ans.append(l)
        _x = x
        l = 1
ans.append(l)

# import math

_ans = 0
if s[0] == '<':
    while len(ans)>1:
        a = ans.pop()
        b = ans.pop()
        _ans += (max(a,b)*(max(a,b)+1))//2
        _ans += (min(a,b)-1)*(min(a,b))//2
    if len(ans)==1:
        c = ans.pop()
        _ans += c*(c+1)//2
else:
    d = ans.pop()
    _ans += d*(d+1)//2
    while len(ans)>1:
        a = ans.pop()
        b = ans.pop()
        _ans += (max(a,b)*(max(a,b)+1))//2
        _ans += (min(a,b)-1)*(min(a,b))//2
    if len(ans)==1:
        c = ans.pop()
        _ans += c*(c+1)//2

print(_ans)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

S = input()

# "<" then flag=0
# ">" then flag=1

if(S[0] == "<"):
    flag=0
else:
    flag=1

sum_count = 0
count=1
tmp_count = 0
for i in range(1, len(S)):
    if(S[i-1] == "<" and S[i] == "<"):
        count+=1
        tmp_count += 1
        
    elif(S[i-1] == "<" and S[i] == ">"):
        sum_count += int(((count-1)*count)/2)
        #reset
        count=1
        
    elif(S[i-1] == ">" and S[i] == "<"):
        if(tmp_count > count):
            sum_count += int(((count+1)*count)/2 + (tmp_count - count))
        else:
            sum_count += int(((count+1)*count)/2)
        #reset
        count=1
        tmp_count = 1
        
    elif(S[i-1] == ">" and S[i] == ">"):
        count+=1

if(S[-1] == ">"):
    if(tmp_count > count):
        sum_count += int(((count+1)*count)/2 + (tmp_count - count))
    else:
        sum_count += int(((count+1)*count)/2)
else:
    sum_count += int(((count+1)*count)/2)
  
  
print(sum_count)

Submission status: Wrong Answer

Solution code:
s = input()
s0 = s[0]
count = 1
nodes = []
ans = 0
for i in range(1, len(s)):
  if s0 == s[i]:
    count += 1
  elif s0 == '>':
    s0 = s[i]
    nodes.append(-count)
    count = 1
  else:
    s0 = s[i]
    nodes.append(count)
    count = 1
if s0 == '>':
  nodes.append(-count)
else:
  nodes.append(count)
print(nodes)

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

Submission status: Wrong Answer

Solution code:
S = input().strip()
V = []
for i in range(len(S)-1):
    if S[i]==">" and S[i+1]=="<":
        V.append(i+1)
if S[-1]==">":
    V.append(len(S))
B = [0 for _ in range(len(S)+1)]
for i in range(len(S)):
    if S[i]==">":
        B[i+1] = B[i]-1
    else:
        B[i+1] = B[i]+1
for j in V:
    if B[j]<0:
        B[j] = 0
        cur = j-1
        while cur>=0 and S[cur]==">":
            B[cur] = max(B[cur],B[cur+1]+1)
            cur -= 1
        cur = j
        while cur<len(S) and S[cur]=="<":
            B[cur+1]=B[cur]+1
            cur += 1
    elif B[j]>0:
        B[j] = 0
        cur = j-1
        while cur>=0 and S[cur]==">":
            if cur-1>=0 and S[cur-1]==">":
                B[cur] = B[cur+1]+1
            cur -= 1
        cur = j
        while cur<len(S) and S[cur]=="<":
            B[cur+1] = B[cur]+1
            cur += 1
print(sum(B))

Submission status: Wrong Answer

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


s = input()
ans = 0
if len(set(s)) == 1:
    ss = len(s)
    ans = ss*(ss+1)
    exit()

ss = s.replace('><' , '> <')
lst = ss.split()

for l in lst:
    a = l.count('<')
    b = l.count('>')
    
    if a == 0:
        ans += f(b)
    elif b == 0:
        ans += f(a)
    else:
        mn = min(a,b)
        mx = max(a,b)
        ans += f(mx) + f(mn-1)
print(ans)

Submission status: Wrong Answer

Solution code:
def count_string(S):
    count_of_str = []
    count = 1
    before = None
    for i, s in enumerate(S, 1):
        if before is None:
            before = s
            continue
        else:
            if s == before:
                count += 1
                before = s
            else:
                count_of_str.append(count)
                count = 1
                before = s

            if len(S) == i:
                count_of_str.append(count)
    return count_of_str

S = input()
count_list = count_string(S)

sum_val = 0
sum_val += sum(sum(range(i)) for i in count_list)
if S.startswith('<'):
    it = iter(count_list)
else:
    it = iter(count_list[1:])
try:
    for c in it:
        sum_val += max(c, next(it))
except:
    pass
if S.endswith('<'):
    sum_val += count_list[-1]
print(sum_val)

Submission status: Wrong Answer

Solution code:
s = input()

def pa(ai, an, n):
    #print(ai,an,n)
    s = (ai+an)*n//2
    #print('pa',s) 
    return s


c = []
ant = s[0]
cont = 1
for i in s[1:]:
    if i != ant:    
        c.append((cont, ant))
        ant = i
        cont = 1
    else:   
        cont += 1
c.append((cont, ant))

soma = 0

for x in range(len(c)):
    i = c[x]
    if i[1] == '<':
        soma += pa(0, i[0]-1, i[0])
    else:
        soma += pa(i[0], 1, i[0])
        off = max(0, c[x-1][0] - i[0])
        #print('off',off)
        soma += off

if c[-1][1] == '<':
    soma += c[-1][0]
    
print(soma)

Submission status: Wrong Answer

Solution code:
instr = input()
s = list(instr)

lbidx = [i for i, x in enumerate(s) if x == '>']
rbidx = [i for i, x in enumerate(s) if x == '<']

ans = 1
tmp = 1

for i in range(1, len(lbidx)):
    if lbidx[i] == lbidx[i-1] + 2:
        ans += tmp
        tmp += 1
    else:
        ans += (tmp + 1)
        tmp = 1

tmp = 1
for i in range(1, len(rbidx)):
    tmp = 1
    if rbidx[i] == rbidx[i-1] + 2:
        ans += tmp
        tmp += 1
    else:
        ans += (tmp + 1)
        tmp = 1

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
a=[]
b=1
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        b+=1
    elif s[i]!=s[i+1]:
        a.append(b)
        b=1
    if i==len(s)-2:
        a.append(b)

if len(a)%2==0:
    if s[0]=="<":
        for i in range(0,len(a),2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1
    else :
        for i in range(1,len(a)-1,2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1

else:
    if s[0]=="<":
        for i in range(0,len(a)-1,2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1
    else :
        for i in range(1,len(a),2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1   
#print(a)
def wa(n):
    return (n+1)*n//2
d=[]
if len(a)==1:
    print(wa(a[0]-1))
else:
  for i in range(len(a)):
    d.append(wa(a[i]))
  print(sum(d))

Submission status: Wrong Answer

Solution code:
S=input()

ans=0
mae,now=0,0
for i in range(1,len(S)):
  if S[i-1]!=S[i]:
    if S[i]=='<':
      if now!=1:
        if mae>=now:
          ans+=int((now-1)*now/2)
        else:
          ans+=int(now*(now+1)/2)
      mae=now
      now=1
    else:
      ans+=int((now-1)*now/2)
      mae=now
      now=0
  now+=1
if now>1:
  if S[-1]=='<':
    ans+=int((now-1)*now/2)
  else:
    ans+=int(now*(now+1)/2)
print(ans)

Submission status: Wrong Answer

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

i = 0
total = 0

def suma(n):
    if n <= 1:
        return 0
    return (n-1)*n//2

while True:
    j = S.find('><', i)
    if j == 0:
        total += 1
        i = j+1
    elif j > 0:
        t = S[i:j+1]
        tl = len(t)
        tc_s = t.count('<')
        tc_b = t.count('>')
        if t == tc_s or tl == tc_b:
            total += suma(tl)
        elif tc_s >= tc_b:
            total += suma(tc_s+1) + suma(tc_b)
        elif tc_s < tc_b:
            total += suma(tc_s) + suma(tc_b+1)
        i = j+1
    else:
        t = S[i:]
        tl = len(t)
        tc_s = t.count('<')
        tc_b = t.count('>')
        if t == tc_s or tl == tc_b:
            total += suma(tl)
        elif tc_s > tc_b:
            total += suma(tc_s+1) + suma(tc_b-1)
        elif tc_s < tc_b:
            total += suma(tc_s-1) + suma(tc_b+1)
        else:
            total += suma(tc_s+1) + suma(tc_b)
        break
print(total)

Submission status: Wrong Answer

Solution code:
S = input()
cnt1=  0
cnt2 = 0
tmp= 1
tmp_point= 1
point = 1
S0 = S[0]
SS =  S[1:]
for i in SS:
    tmp_point+=1
    if i == S0 and i =='<':
        tmp  +=1
        if cnt1 <= tmp:
            cnt1 = tmp
            if cnt1 >= cnt2:
                point =  tmp_point
    elif i==S0 and i =='>':
        tmp  +=1
        if cnt2 <= tmp:
            cnt2 = tmp
            if cnt2 >=cnt1:
                point =  tmp_point
    elif i!=S0:
        tmp = 1
    S0 = i
#     print(i,point,tmp_point)
ans = 0
if cnt1 >  cnt2:
    cnt = cnt1
else:
    cnt = 0

S1 = S[:point]
S2 =  S[point:]
# print(point,'point')
# print('S1',S1)
# print('S2',S2)

for i  in  S2:
    ans = ans+cnt
    if i == '<':
        cnt +=1
    if i == '>':
        cnt-=1
#     print('ans',ans)

if cnt1 >  cnt2:
    cnt = cnt1
else:
    cnt = 0
    
# print(ans)
S1 = S1[::-1]
co =0
SSS=[]
for i in S1:
    if i == '<':
        SSS.append('>')
    if i =='>':
        SSS.append('<')
# print(SSS)

for i  in  SSS:
    if i == '<':
        cnt +=1
    if i=='>':
        cnt-=1
    ans = ans+cnt
if S== "<>>":
    print(3)
elif S=="><<":
    print(4)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
moji = list(input())
listlist=[]
inlist=[]
result=0
if moji[0]=='>':
    inlist.append(2)
else:
    pass
for i in range(len(moji)-1):
    if moji[i] == '>' and moji[i+1]=='<':
        listlist.append(inlist)
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)):
            result += m
        for n in range(inlist.count(2)):
            result += n
        inlist=[]
    elif moji[i] == '>' and moji[i+1]=='>':
            inlist.append(1)
    elif moji[i] == '<' and moji[i+1]=='<':
            inlist.append(2)
    elif moji[i] == '<' and moji[i+1]=='>':
            inlist.append(3)
if moji[len(moji)-2] == '>' and moji[len(moji)-1]=='<':
    result +=1
elif moji[len(moji)-2] == '>' and moji[len(moji)-1]=='>':
    pass
elif moji[i] == '<' and moji[i+1]=='<':

        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)):
            result += m
        for n in range(inlist.count(2)):
            result += n

elif moji[i] == '<' and moji[i+1]=='>':
    pass

print(result)

Submission status: Wrong Answer

Solution code:
s = input()

def pa(ai, an, n):
    #print(ai,an,n)
    s = (ai+an)*n//2
    #print('pa',s) 
    return s


c = []
ant = s[0]
cont = 1
for i in s[1:]:
    if i != ant:    
        c.append((cont, ant))
        ant = i
        cont = 1
    else:   
        cont += 1
c.append((cont, ant))

soma = 0

for x in range(len(c)):
    i = c[x]
    if i[1] == '<':
        soma += pa(0, i[0]-1, i[0])
    else:
        soma += pa(i[0], 1, i[0])
        off = max(0, c[x-1][0] - i[0])
        #print('off',off)
        soma += off

if c[-1][1] == '<':
    soma += 1
    
print(soma)

Submission status: Wrong Answer

Solution code:
s = input()
s0 = s[0]
count = 1
nodes = []
ans = 0
for i in range(1, len(s)):
  if s0 == s[i]:
    count += 1
  elif s0 == '>':
    s0 = s[i]
    nodes.append(-count)
    count = 1
  else:
    s0 = s[i]
    nodes.append(count)
    count = 1
if s0 == '>':
  nodes.append(-count)
else:
  nodes.append(count)
for i in range(1, len(nodes)):
  if nodes[i] < 0:
    if abs(nodes[i]) > abs(nodes[i - 1]):
      nodes[i] = abs(nodes[i])
      nodes[i - 1] -= 1
    else:
      nodes[i] = abs(nodes[i])
      nodes[i] -= 1

for i in nodes:
  ans += (i * (i + 1)) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
# ><
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()
L = []
t = 1
t_str = ''
for i in range(len(S)-1):
    if i == 0:
        t = 1
        t_str = S[i]

    if t_str == S[i] and S[i]==S[i+1]:
        t += 1
    else:
        L.append(t)
        t = 1
        t_str = S[i+1]
    
    if i == len(S)-2:
        L.append(t)

# print(L)
odd = 0
even = 0
for i in range(len(L)):
    if i%2 == 0:
        odd = 0
        even = 0

        odd = L[i]
    
    if i%2 == 1:
        even = L[i]
        if odd < even:
            L[i-1] -= 1
        elif odd > even:
            L[i] -= 1
# print(L)
ans = 0
for i in range(len(L)):
    l = L[i]
    ans += (l*(l+1))/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
from itertools import groupby

s = input()
a = [sum(1 for _ in g) for _, g in groupby(s)]
r = abs(sum(a[0::2]) - sum(a[1::2]))
ans = 0
for i in a:
  ans += i*(i+1)//2
sl = s.count("><")
print(ans -sl -r)

Submission status: Wrong Answer

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

i = 0
total = 0

def suma(n):
    if n <= 1:
        return 0
    return (n-1)*n//2

while True:
    j = S.find('><', i)
    if j > 0:
        t = S[i:j+1]
        tl = len(t)
        tc_s = t.count('<')
        tc_b = t.count('>')
        if t == tc_s or tl == tc_b:
            total += suma(tl)
        elif tc_s >= tc_b:
            total += suma(tc_s+1) + suma(tc_b)
        elif tc_s < tc_b:
            total += suma(tc_s) + suma(tc_b+1)
        i = j+1
    else:
        t = S[i:]
        tl = len(t)
        tc_s = t.count('<')
        tc_b = t.count('>')
        if t == tc_s or tl == tc_b:
            total += suma(tl)
        elif tc_s > tc_b:
            total += suma(tc_s+1) + suma(tc_b-1)
        elif tc_s < tc_b:
            total += suma(tc_s-1) + suma(tc_b+1)
        else:
            total += suma(tc_s+1) + suma(tc_b)
        break
print(total)

Submission status: Wrong Answer

Solution code:
s=input()
a=[]
b=1
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        b+=1
    elif s[i]!=s[i+1]:
        a.append(b)
        b=1
    if i==len(s)-2:
        a.append(b)

if len(a)%2==0:
    if s[0]=="<":
        for i in range(0,len(a),2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1
    else :
        for i in range(1,len(a)-1,2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1

else:
    if s[0]=="<":
        for i in range(0,len(a)-1,2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1
    else :
        for i in range(1,len(a),2):
            if a[i]>=a[i+1]:
                a[i+1]-=1
            else:
                a[i]-=1   
#print(a)
def wa(n):
    return (n+1)*n//2
d=[]
for i in range(len(a)):
    d.append(wa(a[i]))
print(sum(d))

Submission status: Wrong Answer

Solution code:
from sys import stdin 
s = stdin.readline().rstrip()
a = [0] * (len(s) + 1)
t = 0
for i in range(len(s)):
    if i == 0:
        if s[i] == '<':
            k = 0
        else:
            k = 1
    if s[i] == '<' and k == 0:
        a[i+1] = a[i] + 1
    elif s[i] == '<' and k == 1:
        if a[i] < 0:
            min = (-1) * a[i]
            a[i] = 0
            for j in range(t, i):
                a[j] += min
            if t > 1:
                if a[t-2] > a[t]:
                    a[t-1] = a[t-2] + 1
                else:
                    a[t-1] = a[t] + 1
            else:
                a[t-1] = a[t] + 1
        else:
            a[i] = 0
        a[i+1] = a[i] + 1
        k = 0
    elif s[i] == '>' and k == 1:
        a[i+1] = a[i] - 1
    elif s[i] == '>' and k == 0:
        a[i+1]
        t = i+1
        k = 1
    if i == len(s)-1 and s[i] == '>':
        if a[i+1] < 0:
            min = (-1) * a[i+1]
            a[i+1] = 0
            for j in range(t, i+1):
                a[j] += min
        if t > 1:
            if a[t-2] > a[t]:
                a[t-1] = a[t-2] + 1
            else:
                a[t-1] = a[t] + 1
        else:
            a[t-1] = a[t] + 1
print(sum(a))

Submission status: Wrong Answer

Solution code:
s=list(input())

i=1
ans=0
mode=2
con=1
anslist=[]
if s[0]==">":
  mode=0
else:
  mode=1


while i!=len(s):

  if s[i]==">":
    if mode==0:
      con+=1
    else:
      anslist.append([con,"<"])



      mode=0
      con=1
  else:
    if mode==1:
      con+=1
    else:
      anslist.append([con,">"])

      mode=1
      con=1
  i += 1

if s[-1]=="<":
  anslist.append([con, "<"])

else:
  anslist.append([con, ">"])


i=0
while i!=len(anslist):
  try:
    if anslist[i][1]=="<":
      if anslist[i][0]<=anslist[i+1][0]:
        anslist[i][0]=anslist[i][0]-1
    else:
      if anslist[i][0]<=anslist[i-1][0]:
        anslist[i][0]=anslist[i][0]-1

  except:
    pass
  i+=1



i=0
ans=0
while i!=len(anslist):
  ans+=anslist[i][0]*(anslist[i][0]+1)/2
  i+=1
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

# N,M = list(map(int, input().split()))

S = input()
set_array = []
prev_set_len = 0
total = 0

prev_check_point = 0
mountains = []
valleys = [0]
for i in range(len(S)-1):
    if S[i] == "<" and S[i+1] == ">":
        mountains.append(i+1)
    elif S[i] == ">" and S[i+1] == "<":
        valleys.append(i+1)

valleys.append(len(S))

if len(mountains) == 0 and len(valleys) == 2:
    print((len(S)+1)*len(S)//2)
    exit()
if len(mountains) == 0 and len(valleys) == 3:
    left = valleys[1]
    right = len(S) - valleys[1]
    total += (left+1)*left//2
    total += (right+1)*right//2
    print(total)
    exit()

for i, mountain in enumerate(mountains):
    left = mountain - valleys[i]
    right = valleys[i+1] - mountain

    if left > right:
        total += (left+1)*left//2
        total += (right-1+1)*(right-1)//2
    else:
        total += (right+1)*right//2
        total += (left-1+1)*(left-1)//2

if valleys[-2] > mountains[-1]:
    right = len(S) - valleys[-2]
    total += (right+1)*right//2
if valleys[1] < mountains[0]:
    left = valleys[1]
    total += (left+1)*left//2

print(total)

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    s = input()
    # s = '<>>'
    n_list = np.zeros(len(s)+1)

    if s[0] == '<':
        n_list[0] = 0
    else:
        n_list[1] = 1

    for i in range(1, len(s)+1):
        if s[i-1] == '<':
            n_list[i] = n_list[i-1]+1
        else: # i = >
            j = i # jは左側の                           文字のインデックス
            k = 1                          
            for j in range(i, 1, -1):
                if s[j-1] == '<':
                    n_list[j] = n_list[j-1]+1
                    break
                n_list[j-1] = k                
                j-=1
                k+=1
        # print('i={} {}'.format(i, n_list))    
                
    print(int(sum(n_list)))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#標準入力から文字列Sを取得
S = input()

#文字列Sの長さを取得
N = len(S)

#空のリストを用意
a = [0]

#<と>の順番に応じて初期の山の形を決定
for i in range(N):
    if S[i] == '<':
        a.append(a[i]+1)
    else:
        a.append(a[i]-1)

#aの最小値
min(a)

#山をずらす値
shift_value = 0 - min(a)

#aの全要素にシフト値を加える
newa = [n+shift_value for n in a]

#端の補正
if S[0] == '<':
    newa[0] = 0
if S[N-1] == '>':
    newa[N] = 0

#極小値を0に置き換える
for i in range(N-1):
    if S[i] == '>' and S[i+1] == '<':
        a[i+1] = 0

#aの全要素の和
sum(newa)

Submission status: Wrong Answer

Solution code:
import numpy as np
S = input()
N = len(S)
good = np.zeros(N)
for i in range(N):
    if S[i] == '>':
        good[i] = good[i-1] + 1
    else:
        good[i] = good[i-1] - 1
minN = np.amin(good)
good -= minN
print(int(np.sum(good)))

Submission status: Wrong Answer

Solution code:
import sys

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

from_left = []
from_right = []
less_row = 0
more_row = 0
for i, c in enumerate(inp):
    if c == "<":
        less_row += 1
    else:
        if less_row:
            from_left.append((less_row, less_row * (less_row + 1) // 2))
        less_row = 0

    r_i = N - i
    if inp[r_i] == ">":
        more_row += 1
    else:
        if more_row:
            from_right.append((more_row, more_row * (more_row + 1) // 2))
        more_row = 0

if less_row:
    from_left.append((less_row, less_row * (less_row + 1) // 2))
if more_row:
    from_right.append((more_row, more_row * (more_row + 1) // 2))

ans = 0
if inp[-1] == "<":
    ans += from_left.pop()[1]
if inp[0] == ">":
    ans += from_right.pop(0)[1]

for i, (last, tri) in enumerate(from_left):
    r_last, r_tri = from_right[i]
    ans += tri + r_tri - min(last, r_last)

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# agc040/agc040_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    sum_r = 0
    ls_max = 0
    i = 0
    while i < len(S):
        if S[i] == '<':
            next_lg = S.find('>', i + 1)
            if next_lg == -1:
                next_lg = len(S)
            ls_len = next_lg - i
            ls_max = ls_len - 1
            sum_r += ls_len * (ls_len - 1) / 2
            i = next_lg
        else:
            next_ls = S.find('<', i + 1)
            if next_ls == -1:
                next_ls = len(S)
            lg_len = next_ls - i
            lg_max = lg_len
            sum_r += lg_len * (lg_len + 1) / 2
            if ls_max >= lg_max:
                sum_r += ls_max + 1 - lg_max
            i = next_ls
    if S[-1] == '<':
        sum_r += 1
    print(int(sum_r))
    return

main()

Submission status: Wrong Answer

Solution code:
from itertools import groupby

def all_sum(n):
    a = 0
    for val in range(n+1):
        a += val
    return a

s = list(input())

trans_L = []
yazi_L = []

for key, value in groupby(s):
    num = len(list(value))
    trans_L.append(num)
    yazi_L.append(key)

print(s)
print(trans_L)


ans = 0

for i in range(len(trans_L)):
    if i != len(trans_L)-1 and trans_L[i] == 1 and trans_L[i+1] == 1:           
        ans += 1
    elif trans_L[i] !=1:
        ans += all_sum(trans_L[i])


if trans_L[0]==1 and yazi_L[0] == ">":
    ans +=1
elif trans_L[-1] == 1 and yazi_L =="<":
    ans +=1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    # s = input()
    s = '<>>><<><<<<<>>><'
    n_list = np.zeros(len(s)+1)

    if s[0] == '<':
        n_list[0] = 0
    else:
        n_list[1] = 1

    for i in range(1, len(s)+1):
        if s[i-1] == '<':
            n_list[i] = n_list[i-1]+1
        else: # i = >
            j = i # jは左側の                           文字のインデックス
            k = 1                          
            for j in range(i, 1, -1):
                if s[j-1] == '<':
                    n_list[j] = n_list[j-1]+1
                    break
                n_list[j-1] = k                
                j-=1
                k+=1
        # print('i=', i, n_list)        
                
    print(int(sum(n_list)))


if __name__ == "__main__":
    main()