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()
N = len(S)
tmp = 1
List = []
for i in range(1, N):
    if S[i] != S[i-1]:
        List.append(tmp)
        tmp = 1
    else:
        tmp+=1
List.append(tmp)
ans = 0
if S[0] == '<':
    for i in range(0, len(List)-1, 2):
        r = List[i]
        l = List[i+1]
        ans+=r*(r-1)//2
        ans+=max(r, l)
        ans+=l*(l-1)//2
    if len(List)%2 == 1:
        ans+=List[-1]
    print(ans)
else:
    ans+=List[0]
    for i in range(1, len(List)-1, 2):
        r = List[i]
        l = List[i+1]
        ans+=r*(r-1)//2
        ans+=max(r, l)
        ans+=l*(l-1)//2
    if len(List)%2 == 0:
        ans += List[-1]
    print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input()) + ['_']
A = [0] * (len(S))
cur = 0
for i in range(len(S)-1):
    if S[i] == '<':
        cur = 0
        k = 0
        j = i + 1
        while S[j] == '>':
            k += 1
            j += 1
            cur += 1
        A[i+1] = max(A[i]+1, k)
    else:
        if cur >= 2:
            A[i+1] = cur - 1
            cur -= 1
        else:
            A[i+1] = 0
print(sum(A))

Submission status: Wrong Answer

Solution code:
S=input()
c=0
for i in range(0,len(S)+1):
  c1=0
  c2=0
  for j in range(0,i-1):
    if S[i-j-1]=='<':
      c1+=1
    else:
      break
  for k in range(i,len(S)):
    if S[k]=='>':
      c2+=1
    else:
      break
  if c1<c2:
    c+=c2
  else:
    c+=c1
print(c)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
from bisect import bisect_left,bisect_right
import sys,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
ass = []
tmp = ''
cnt = 0
for i in range(n):
    if i == 0:
        tmp = s[i]
        cnt = 1
        continue
    if tmp == s[i]:
        cnt += 1
    else:
        tmp = s[i]
        ass.append(cnt)
        cnt = 1
ass.append(cnt)
l = len(ass)
res = 0
if s[0] == '<':
    for i in range(l)[::2]:
        if i == l-1:
            res += (ass[i]+1)*ass[i]//2
            continue
        mm = max(ass[i],ass[i+1])
        nn = min(ass[i],ass[i+1])
        # print(mm,nn)
        res += (mm+1)*mm//2 + (nn-1)*nn//2
        print(res)
else:
    res += (ass[0]+1)*ass[0]//2
    for i in range(1,l)[::2]:
        if i == l-1:
            res += (ass[i]+1)*ass[i]//2
            continue
        mm = max(ass[i],ass[i+1])
        nn = min(ass[i],ass[i+1])
        res += (mm+1)*mm//2 + (nn-1)*nn//2
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N - 1):
  if S[i] == '<':
    a[i + 1] = a[i] + 1
  else:
    a[i + 1] = a[i] - 1
    
b = [n - min(a) for n in a]

print(sum(b))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

s = input()
n = len(s) + 1

less = np.zeros(n)
more = np.zeros(n)

for i, c in enumerate(s):
    if c == '<':
        more[i+1] = more[i] + 1
    else:
        less[n-i-2] = less[n-i-1] + 1

rst = [max(m, l) for m, l in zip(more, less)]
print(int(sum(rst)))

Submission status: Wrong Answer

Solution code:
S = input()

L = []

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

ans = 0
if S[0] == "<":
    if len(L) > 1:
        ans += max(0, L[1]-L[0])
    for i in range(len(L)):
        if i%2 == 0:
            ans += L[i]*(L[i]+1)//2
        else:
            ans += L[i]*(L[i]-1)//2
else:
    for i in range(len(L)):
        if i%2 == 1 or i == 0:
            ans += L[i]*(L[i]+1)//2
        else:
            ans += L[i]*(L[i]-1)//2
            
print(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]))
l = len(a)
print(sum(a) + (l*r) -2)

Submission status: Wrong Answer

Solution code:
S = input()

N = len(S) + 1
t = [0] * N
p = ''
for i in range(N - 2, -1, -1):
  if p == '>':
    t[i + 1] = t[i + 2] + 1
  p = S[i]
for i in range(N - 1):
  if S[i] == '<':
    t[i + 1] = max(t[i + 1], t[i] + 1)
print(sum(t))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))



S=one_str()

temp = S.split("><")

sums=0
for i in temp:
    left = i.count(">")+1
    right= i.count("<")
    if sums!=0:
        right+=1
    
    maxs = max(left,right)
    mins = min(left,right) 
    maxs_array=[value for value in range(maxs+1)]
    mins_array=[value for value in range(mins)]

    sums += sum(maxs_array)
    sums += sum(mins_array)

print(sums)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
t = 0
tmp = 0
a = 0
for c in s:
    if c == '<':
        tmp = 0
        t += 1
        a = t
    else:
        tmp += 1
        t = min(t - 1, 0)
    if t < 0:
        ans += tmp - (1 if a > tmp else 0)
        t += 1
    ans += t
print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
l_ans = [0 for _ in range(len(s)+1)]
r_ans = [0 for _ in range(len(s)+1)]
ans = [0 for _ in range(len(s)+1)]
l_level = 0
r_level = 0
for i in range(len(s)):
    if s[i] == '<':
        l_level += 1
    else:
        l_level = 0
    l_ans[i+1] = l_level

for i in range(len(s)):
    if s[-i] == '<':
        r_level = 0
    else:
        r_level += 1
    r_ans[-(i+1)] = r_level

for i in range(len(ans)):
    ans[i] = max(l_ans[i], r_ans[i])
print(sum(ans))

Submission status: Wrong Answer

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

ls = [0]*n



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

m = min(ls)

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

ans = sum(ls)
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)+1
llst=[0 for i in range(N)]
rlst=[0 for i in range(N)]
for i in range(N-1):
  if S[i]=='<':
    llst[i+1]=llst[i]+1
for i in range(N-2, 0, -1):
  if S[i]=='>':
    rlst[i]=rlst[i+1]+1
ans=0
for i in range(N):
  ans+=max(llst[i], rlst[i])
print(ans)

Submission status: Wrong Answer

Solution code:
s = ">" + input() + "<"
n = len(s)-1
a = [10**10 for _ in range(n)]

for i in range(n):
	if s[i] == ">" and s[i+1] == "<":
		a[i] = 0

for i in range(1, n):
	if s[i] == "<":
		a[i] = min(a[i], a[i-1]+1)


for i in range(n-1, 1, -1):
	if s[i] == ">":
		if a[i-1] == 10**10:
			a[i-1] = a[i]+1
		else:
			a[i-1] = max(a[i-1], a[i]+1)


print(sum(a))

Submission status: Wrong Answer

Solution code:
print(sum(range(input().count(">") + 1)))

Submission status: Wrong Answer

Solution code:
S=input()
c=0
for i in range(0,len(S)):
  c1=0
  c2=0
  for j in range(0,i):
    if S[i-j]=='<':
      c1+=1
    else:
      break
  for k in range(i+1,len(S)):
    if S[k]=='>':
      c2+=1
    else:
      break
  if c1<c2:
    c+=c2
  else:
    c+=c1
print(c)

Submission status: Wrong Answer

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


for i in range(N):
  num = 0
  if S[i] == '<':
    L.append(num + 1)
  else:
    L.append(num - 1)

L.sort()
A = 0 - L[0]
result = sum(L) + A * len(L)
print(result)

Submission status: Wrong Answer

Solution code:
S = list(input())
counter = 0
for i in range(len(S)):
    if S[i] == ">":
        counter += S[i:].count(">")


print(counter)

Submission status: Wrong Answer

Solution code:
s=input()
print(len(s))

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

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

s = input()
l = [s[0]]
for c in s[1:]:
    if c in l[-1]:
        l[-1] += c
    else:
        l.append(c)
ans = 0
now = 0
for c in l:
    if '>' in c:
        ans -= min(now, len(c))
    ans += sigma(len(c))
    now = len(c)
print(ans)

Submission status: Time Limit Exceeded

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

S=tuple(input().strip())
N=len(S)+1
x = [0]

for i in range(1,N):
    if S[i-1] == '<':
        x.append(x[i-1] + 1)
    else:
        x.append(0)
        for j in range(i):
            if x[i-1-j] == x[i-j]:
                x[i-1-j] += 1
            else:
                break

print(sum(x))

Submission status: Time Limit Exceeded

Solution code:
import sys
S = [ c for c in input()]

#aiは、その数より左側の連続した<の数(Si-1から数える)か、その数より右側の連続した>の数(Siから数える)の大きい方
a = []
for i in range(len(S)+1):
    cnt = [0,0]
    j = i
    while j-1 >= 0:
        if S[j-1] == "<" and j >= 0:
            cnt[0] +=1
            j -= 1
        else:
            break
    
    j = i
    while j <= len(S)-1:
        if S[j] == ">" and j<= len(S)-1:
            cnt[1] +=1
            j += 1
        else:
            break
    if cnt[0] >= cnt[1]:
        a.append(cnt[0])
    else:
        a.append(cnt[1])
    
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
S = input()
A = [0]*(len(S)+1)
for i in range(len(S)+1):
    L = S[:i]
    R = S[i:]
    # print('L=', L)
    # print('R=', R)
    l = 0
    r = 0
    if L != '':
        T = len(L)
        for k in range(T):
            if L[T-k-1] != '<':
                l = k
                break
        else:
            l = T
    if R != '':
        U = len(R)
        for j in range(U):
            if R[j] != '>':
                r = j
                break
        else:
            r = len(R)
    A[i] = max(l, r)
# print(A)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
s=input()

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

total=0
if s[0]=='>':
  cnt=s.find('<')
  if cnt==-1:
    cnt=len(s)
    s=''
  else:
    s=s[cnt:]
  total+=sigma(cnt)
  
flag=True
while flag:
  l=[]
  index1=s.find('>')
  if index1!=-1:
    for i in range(index1):
      l.append(s[i])
    s=s[index1:]
  else:
    l.extend(['<']*len(s))
    s=''
    flag=False
  index2=s.find('<')
  if index2!=-1:
    for i in range(index2):
      l.append(s[i])
    s=s[index2:]
  else:
    l.extend(['>']*len(s))
    s=''
    flag=False
  cnt1=l.count('>')
  cnt2=l.count('<')
  if cnt2<=cnt1:
    total+=sigma(cnt1)+sigma(cnt2-1)
  else:
    total+=sigma(cnt2)+sigma(cnt1-1)

print(total)

Submission status: Time Limit Exceeded

Solution code:
s=input()

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

total=0
cnt=0
while s[0]=='>':
  cnt+=1
  s=s[1:]
  if s=='':
    break
total+=sigma(cnt)
  
flag=True
while flag:
  l=[]
  if '>' in s:
    for i in range(s.find('>')):
      l.append(s[i])
    s=s[s.find('>'):]
  else:
    l.extend(['<']*len(s))
    s=''
    flag=False
  if '<' in s:
    for i in range(s.find('<')):
      l.append(s[i])
    s=s[s.find('<'):]
  else:
    l.extend(['>']*len(s))
    s=''
    flag=False
  if l.count('<')<=l.count('>'):
    total+=sigma(l.count('>'))+sigma(l.count('<')-1)
  else:
    total+=sigma(l.count('<'))+sigma(l.count('>')-1)

print(total)

Submission status: Time Limit Exceeded

Solution code:
S = input()
l = [0]
r = [0]
c = 0
for i in range(len(S)):
    if S[i] == '<':
        c += 1
    else:
        c = 0
    l.append(c)
c = 0
for i in range(len(S)-1,-1,-1):
    if S[i] == '>':
        c += 1
    else:
        c = 0
    r.insert(0, c)
print(sum([max(l[i],r[i]) for i in range(len(S)+1)]))

Submission status: Time Limit Exceeded

Solution code:
def count_seq_l(s):
    tmp_cnt = 0
    for s_tmp in s[::-1]:
        if s_tmp == '<':
            tmp_cnt += 1
        else:
            break

    return tmp_cnt
def count_seq_r(s):
    tmp_cnt = 0
    for s_tmp in s:
        if s_tmp == '>':
            tmp_cnt += 1
        else:
            break
    return tmp_cnt

if __name__ == '__main__':
    S = input()
    res = 0
    for i in range(len(S) + 1):
        l_s = S[:i]
        r_s = S[i:]
        l_cnt = len(l_s.split('>')[-1])
        r_cnt = len(r_s.split('<')[0])
        tmp = max(l_cnt, r_cnt)
        res += tmp
    print(res)

Submission status: Time Limit Exceeded

Solution code:
def count_seq_l(s):
    tmp_cnt = 0
    for s_tmp in s[::-1]:
        if s_tmp == '<':
            tmp_cnt += 1
        else:
            break

    return tmp_cnt
def count_seq_r(s):
    tmp_cnt = 0
    for s_tmp in s:
        if s_tmp == '>':
            tmp_cnt += 1
        else:
            break
    return tmp_cnt

if __name__ == '__main__':
    S = input()
    res = 0
    for i in range(len(S) + 1):
        l_s = S[:i]
        r_s = S[i:]
        l_cnt = count_seq_l(l_s)
        r_cnt = count_seq_r(r_s)
        tmp = max(l_cnt, r_cnt)
        res += tmp
    print(res)

Submission status: Time Limit Exceeded

Solution code:
S = str(input())
N = len(S) + 1
l = [-1] * N
if S[0] == '<':
  l[0] = 0
else:
  i = 0
  while i <= N-2:
    if S[i] == '>':
      i += 1
    else:
      break
  l[0] = i
  
if S[-1] == '>':
  l[-1] = 0
else:
  i = N-2
  cnt = 0
  while i >= 0:
    if S[i] == '<':
      i -= 1
      cnt += 1
    else:
      break
  l[-1] = cnt
  
for i in range(N-2):
  if (S[i]=='>') and (S[i+1]=='<'):
    l[i+1] = 0
  else:
    left = 0
    right = 0
    c1 = i
    c2 = i+1
    while c1 >= 0:
      if S[c1] == '<':
        left += 1
        c1 -= 1
      else:
        break
    while c2 <= N-2:
      if S[c2] == '>':
        right += 1
        c2 += 1
      else:
        break
    num = max(left, right)
    l[i+1] = num
ans = sum(l)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = input()
a = []
ans = 0
for i in range(len(s)):
    dainari = 0
    syonari = 0
    for j in reversed(range(i)):
        if s[j] == "<":
            dainari += 1
        else:
            break
    for j in range(i,len(s)):
        if s[j] == ">":
            syonari += 1
        else:
            break
    ans += max(dainari,syonari)
    #print(max(dainari,syonari),s[i],a)
print(ans+(s[-1] == "<"))

Submission status: Time Limit Exceeded

Solution code:
s = input()
a = []
ans = 0
for i in range(len(s)):
    dainari = 0
    syonari = 0
    for j in reversed(range(i)):
        if s[j] == "<":
            dainari += 1
        else:
            break
    for j in range(i,len(s)):
        if s[j] == ">":
            syonari += 1
        else:
            break
    a.append(max(dainari,syonari))
    #print(max(dainari,syonari),s[i],a)
print(sum(a)+(s[-1] == "<"))

Submission status: Time Limit Exceeded

Solution code:
s = input()
l = len(s)
idx = []
for i in range(l-1):
    if s[i] == ">" and s[i+1] == "<":
        idx.append(i+1)

idx = [0]+idx+[l]

L = []
cnt = 0
for i in range(len(idx)-1):
    L = s[idx[i]:idx[i+1]]

    for j in range(len(L)):
        a = L.count("<")
        b = L.count(">")
        k = max(a,b)
        r = min(a,b)
    if r >=1:
        cnt += k*(k+1)//2 + r*(r-1)//2
    else:
        cnt += k*(k+1)//2

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
s = input()

cnt_l = [0]*(len(s)+1)
cnt_r = [0]*(len(s)+1)

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

    if i == len(s):
        cnt_r[i] = 0
    else:
        if s[i] == ">":
            j = i
            tr = 0
            while j < len(s) and s[j] == ">":
                tr += 1
                j += 1
            cnt_r[i] = tr
        else:
            cnt_r[i] = 0

ans = 0
for l, r in zip(cnt_l, cnt_r):
    ans += max(l, r)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = str(input())

l = [1 if c == "<" else -1 for c in list(s)]

def leftmore(i):
    num = 0
    while True:
        if i == 0:
            break
        elif s[i-1] == "<":
            i -= 1
            num += 1
        else:
            break
    return num

def rightless(i):
    num = 0
    while True:
        if i == len(s):
            break
        elif s[i] == ">":
            i += 1
            num += 1
        else:
            break
    return num

sumlist = [0] * (len(s)+1)
for i in range(len(sumlist)):
    sumlist[i] = max(leftmore(i),rightless(i))


print(sum(sumlist))

Submission status: Time Limit Exceeded

Solution code:
s = str(input())
l = [1 if c == "<" else -1 for c in list(s)]

def leftmore(i):
    num = 0
    while True:
        if i == 0:
            break
        elif s[i-1] == "<":
            i -= 1
            num += 1
        else:
            break
    return num

def rightless(i):
    num = 0
    while True:
        if i == len(s):
            break
        elif s[i] == ">":
            i += 1
            num += 1
        else:
            break
    return num

sumlist = [0] * (len(s)+1)
for i in range(len(sumlist)):
    sumlist[i] = max(leftmore(i),rightless(i))


print(sum(sumlist))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()
    n = len(S)+1
    ret = 0
    for i in range(n):
        left = S[:i]
        l = left[::-1].find('>')
        if l==-1:
            l=len(left)
        right = S[i:]
        r = right.find('<')
        if r==-1:
            r=len(right)
#        print(i,l,r)
#        print(left,right)
        ret += max(l,r)
    print(ret)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[84]:


S = input() + " "


# In[85]:


ans = [0]*(len(S)+1)
for i in range(len(S)):
    count_left = 0
    count_right = 0
    for j in range(i):
        if S[i-j-1] == "<":
            count_left += 1
        else:
            j -= 1
            break
    for k in range(i,len(S)):
        if S[k] == ">":
            count_right += 1
        else:
            k -= 1
            break
    ans[i] = max(count_left, count_right)
#     print(count_left, count_right)
#     print(S[i-j-1:i], S[i:k+1])
# print(ans)
print(sum(ans))


# In[ ]:

Submission status: Time Limit Exceeded

Solution code:
s = list(input())
n = len(s) + 1
a = [0]*n
for i in range(n):
    right = 0
    left = 0
    if i != n-1:
        j = i
        while True:
            if j == n-1 or s[j] != '>':
                break
            right += 1
            j += 1
    if i != 0:
        j = i-1
        while True:
            if j == -1 or s[j] != '<':
                break
            left += 1
            j -= 1
    a[i] = max(right, left)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
s = input()

# now = 0
# left = 0
# right = 0
ans = []
for i in range(len(s) + 1):

    left = 0
    right = 0
    # 左側
    for j in range(i, 0, -1):
        if s[j - 1] != '<':
            break
        else:
            left += 1
    # 右側
    for j in range(i, len(s)):
        if s[j] != '>':
            break
        else:
            right += 1
    ans.append(max(left, right))
# print(ans)
print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


def getCount(start):
    l = r = 0
    for i in range(start-1, -1, -1):
        if a[i] == "<":
            l += 1
        else:
            break
    for i in range(start, n):
        if a[i] == ">":
            r += 1
        else:
            break

    return max(l, r)


a = input()
n = len(a)
c = 0
total = 0
flip = a[0]
for i in range(n+1):
    temp = getCount(i)
    total += temp
print(total)

Submission status: Time Limit Exceeded

Solution code:
S=input()
l=len(S)
c=0
for i in range(l+1):
  a=0
  b=0
  for j in range(i-1,-1,-1):
    if S[j]=='<':
      a+=1
    else:
      break
  for k in range(i,l):
    if S[k]=='>':
      b+=1
    else:
      break
  c+=max(a,b)
print(c)

Submission status: Time Limit Exceeded

Solution code:
s = input()
de_num = 0
le_num = 0
ans = [0]*(len(s)+1)

for i in range(len(s)+1):
    mae = 0
    ato = 0
    j = i
    k = i
    while j > 0 and s[j-1] == "<":
        mae += 1
        j -= 1
    while k < len(s) and s[k] == ">":
        ato += 1
        k += 1
    ans[i] = max(mae,ato)

print(sum(ans))

Submission status: Time Limit Exceeded

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

s = input()
n = len(s)
ans = 0 
arr = []

# calc
for i in range(n+1):
    # right direction
    rcnt = 0 
    for j in range(i, n): 
        if s[j] == '>':
            rcnt += 1
        else:
            break
    # left direction
    lcnt = 0 
    for j in reversed(range(i)):
        if s[j] == '<':
            lcnt += 1
        else:
            break
    arr.append(max(rcnt, lcnt))
    ans += max(rcnt, lcnt)
#print(arr)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
S=input()
N=len(S)+1
LEFT=[0]
RIGHT=[0]
left=0
right=0
for i in range(N-1):
  if S[i]==">":
    left=0
  else:
    left+=1
  LEFT+=[left]
for i in range(N-2,-1,-1):
  if S[i]=="<":
    right=0
  else:
    right+=1
  RIGHT=[right]+RIGHT
ans=0  
for i in range(N):  
  ans+=max(LEFT[i],RIGHT[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
S=input()
N=len(S)+1
LEFT=[0]
RIGHT=[0]
left=0
right=0
for i in range(N-1):
  if S[i]==">":
    left=0
  else:
    left+=1
  LEFT+=[left]
for i in range(N-2,-1,-1):
  if S[i]=="<":
    right=0
  else:
    right+=1
  RIGHT.insert(0,right)
ans=0  
for i in range(N):  
  ans+=max(LEFT[i],RIGHT[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
S = str(input())

N = len(S) + 1

ans = [0] * N


while(1):
    flag = 0
    for i in range(N - 1):
        if(S[i] == '>'):
            if(ans[i] <= ans[i+1]):
                ans[i] += 1
                flag += 1
        if(S[i] == '<'):
            if(ans[i] >= ans[i+1]):
                ans[i+1] += 1
                flag += 1
    if(flag==0):
        break
#print('ans:',ans)
print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
from itertools import takewhile, islice


S = input()
total = 0
for idx in range(len(S) + 1):
    left = sum(1 for _ in takewhile(lambda x: x == "<", reversed(S[:idx])))
    right = sum(1 for _ in takewhile(lambda x: x == ">", islice(S, idx, None)))
    total += max((left, right))
print(total)

Submission status: Time Limit Exceeded

Solution code:
from itertools import takewhile

S = input()
total = 0
for idx in range(len(S) + 1):
    left = sum(1 for _ in takewhile(lambda x: x == "<", reversed(S[:idx])))
    right = sum(1 for _ in takewhile(lambda x: x == ">", S[idx:]))
    total += max((left, right))
print(total)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

ans = []
s = ns()
n = len(s) + 1
now = 0
min_now = 0

ri = deque()
le = deque()

now = 0
for i in range(n-1):
    if s[i] == '<':
        now += 1
    else:
        now = 0
    le.append(now)
now = 0
for i in range(n-1):
    if s[(n-2)-i] == '>':
        now += 1
    else:
        now = 0
    ri.appendleft(now)
le.appendleft(0)
ri.append(0)

for i in range(n):
    ans.append(max(le[i], ri[i]))

print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

ans = []
s = ns()
n = len(s) + 1
now = 0
min_now = 0
for i in range(n):
    left = 0
    right = 0
    offset = 0
    while i - offset - 1 >= 0:
        if s[i - offset - 1] != '<':
            break
        left += 1
        offset += 1
    offset = 0
    while i + offset < n - 1:
        if s[i + offset] != '>':
            break
        right += 1
        offset += 1
    ans.append(max(left, right))

print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
s = list(input())
ans = 0
k = deque()
for i in range(len(s) + 1):
    l, r = i - 1, i
    while l >= 0:
        if s[l] != "<":
            break
        l -= 1
    while r < len(s):
        if s[r] != ">":
            break
        r += 1
    ans += max(i - l - 1, r - i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
s = list(input())
data = [0] * (len(s) + 1)
k = deque()
for i in range(len(s) + 1):
    l, r = i - 1, i
    while l >= 0:
        if s[l] != "<":
            break
        l -= 1
    while r < len(s):
        if s[r] != ">":
            break
        r += 1
    data[i] = max(i - l - 1, r - i)
print(sum(data))

Submission status: Time Limit Exceeded

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

la = [0] * N

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

for i in range(1, N-1):
    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 
    la[i] = max(cnt1, cnt2)

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

print(sum(la))

Submission status: Time Limit Exceeded

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

s='|'+s+'|'

dp=[0]*(n+1)

#数列aの各項a_iについて、左右に連続する'<<<','>>>'の数をそれぞれカウント、
#その最大がa_iの最小値となる
for i in range(n+1):
    max_l=0
    max_r=0
    for l in range(i,-1,-1):
        if s[l]!='<':
            break
        max_l+=1
    for r in range(i+1,n+2):
        if s[r]!='>':
            break
        max_r+=1
    dp[i]=max(max_l,max_r)
#print(dp)
print(sum(dp))

Submission status: Time Limit Exceeded

Solution code:
s = input()
n = len(s)
t = 0
for i in range(n+1):
    l = 0
    r = 0
    for j in range(i)[::-1]:
        if(s[j] == '>'):break
        l += 1
    for j in range(i,n):
        if(s[j] == '<'):break
        r += 1
    t += max(l,r)
print(t)

Submission status: Time Limit Exceeded

Solution code:
s=list(input())

right = [0]

left = [0]

count = 0
for i in range(len(s)):
    if s[i] == '<':
        count += 1
    else:
        count = 0
    right.append(count)
count = 0
for i in range(len(s)-1,-1,-1):
    if s[i] == '>':
        count += 1
    else:
        count = 0
    left.insert(0,count)

ans = 0

for i in range(len(s)+1):
    ans += max(right[i],left[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
ans = []
N = len(S) + 1


def search(n):
    temp = [0, 0]
    # right
    if n != N-1:
        j = n
        ret = 0
        while j < N-1 and S[j] == ">":
            ret += 1
            j += 1
        temp[1] = ret

    # left
    if n != 0:
        j = n - 1
        ret = 0
        while j >= 0 and S[j] == "<":
            ret += 1
            j -= 1
        temp[0] = ret
    return temp


for i in range(N):
    l, r = search(i)
    ans.append(max(l, r))
print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
import re
s = input()
l = []
for i in range(len(s)+1):
    left = s[:i]
    right = s[i:]
    ml = re.match('<+',left[::-1])
    num = 0
    if ml:
        num = ml.end()
    mr = re.match('>+',right)
    if mr:
        num = max(num,mr.end())
    l.append(num)
#print(l)
print(sum(l))