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

ans = [0] * (len(S) + 1)
for i in range(len(S)):
    if S[i] == '<':
        ans[i + 1] = ans[i] + 1

print(ans)

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

Submission status: Wrong Answer

Solution code:
s=input()
a=[0]*(len(s)+1)
b=[0]*(len(s)+1)
flag=0
for i in range(len(s)):
    if s[i]=="<" and flag==0:
        flag=1
        a[i+1]=1
    elif s[i]=="<" and flag==1:
        a[i+1]=a[i]+1
    else:
        flag=0
flag=0
for i in range(len(s)-1,0,-1):
    if s[i]==">" and flag==0:
        flag=1
        b[i]=1
    elif s[i]==">" and flag==1:
        b[i]=b[i+1]+1
    else:
        flag=0
c=[]
for i in range(len(s)+1):
    c.append(max(a[i],b[i]))
print(sum(c))

Submission status: Wrong Answer

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

mn = 0
a = 0
ans = 0
for s in S:
  if s == '<':
    a += 1
  elif s == '>':
    a -= 1
    mn = min(mn,a)    
  
  ans += a
  
ans -= mn * N
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())

a = 0
ans = 0
for s in S:
  if s == '<':
    a += 1
  elif s == '>':
    a = max(a-1,0)
    
  ans += a
  
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
N = len(S) + 1
ary = [0] * N
for i in range(N-1):
    if S[i] == "<":
        ary[i+1] = ary[i] + 1

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

print(sum(ary))

Submission status: Wrong Answer

Solution code:
S=input()
counter = []
curr=S[0]
count=0
for s in S:
    if s == curr:
        count+=1
    else:
        counter.append(count)
        curr = s
        count=1
counter.append(count)

ans = 0
for i in range(0,len(counter) - 1,2):
    if counter[i] > counter[i+1]:
        max = counter[i]
        min = counter[i+1]
    else:
        max = counter[i+1]
        min = counter[i]
    ans += max*(max+1)//2
    ans += min*(min-1)//2
if len(counter)%2 != 0:
    ans += counter[-1]*(counter[-1]+1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
A=input()
length=len(A)
ans=[]
for i in range(1,length):
  right='>'
  left='<'
  right_num=0
  left_num=0
  for j in range(i,length):
    if A[j]!=right:
      break
    else:
      right_num+=1
  for h in range (1,i+1):
    if A[i-h]!=left:
      break
    else:
      left_num+=1 
  ans.append(max(right_num,left_num))

right_1=0
for k in range(0,length-1):
   if A[k]!=right:
    break
   else:
    right_1+=1
ans.append(right_1)

left_1=0
for l in range(0,length-1):
  if A[-1-l]!=left:
    break
  else:
    left_1+=1
ans.append(left_1)

print(sum(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(len(S)):
    if S[i] == ">":
        a[i+1] = a[i] - 1
    elif S[i] == "<":
        a[i+1] = a[i] + 1
    if i > 0:
        if S[i-1] == "<" and S[i] == ">":
            yama = i
        if S[i-1] == ">" and S[i] == "<":
            tani = i
            val = a[tani]
        if a[tani] < 0:
#            print(a)
            for j in range(yama, tani+2):
                a[j] = a[j] - val
#            print(a)
        elif a[tani] > 0:
            for j in range(yama+1, tani+2):
                a[j] = a[j] - val
#print(a)
print(sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    n=len(s)
    A=[0]*(n+1)
    for i in range(0,n):
        if s[i]=="<":
            A[i+1]=A[i]+1
    for i in range(n,1,-1):
        if s[i-1]==">":
            A[i-1]=max(A[i-1],A[i]+1)
    print(sum(A))

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    s=input()
    n=len(s)
    L=[0]*(n+1)
    cunt_l=0
    for i,ss in enumerate(s,1):
        if ss=="<":
            cunt_l+=1
            L[i]=cunt_l
        else:
            cunt_l=0
    G=[0]*(n+1)
    cunt_g=0
    for i in range(n-1,0,-1):
        if s[i]==">":
            cunt_g+=1
            G[i]=cunt_g
        else:
            cunt_g=0
    A=[0]*(n+1)
    for i in range(n+1):
        A[i]=max(L[i],G[i])
    print(sum(A))


if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
S = input()
nums = [0] * (len(S)+1)
pos = 0
count = 0
pre_count = 0
now = '>'
for (i, s) in enumerate(S):
  if s != now:
    if s == '<':
      nums[pos] = max(pre_count, count)
      while pos != i:
        pos += 1
        count -= 1
        nums[pos] = count
    else:
      pos = i
      pre_count = count+1
      count = 1
    now = s
  else:
    count += 1
    if s == '<':
      nums[i] = count
if now == '<':
  nums[i+1] = count+1

print(sum(nums))

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    import numpy as np
    S = input()
    if len(S) >=2:
        S_part_list = []
        prev = S[0]

        memo = 0
        for i, s in enumerate(S):
            # print(i,s)
            if prev == '>' and s == '<':
                S_part_list.append(S[memo:i])
                memo = i
                # print(i)
                # print(prev, s)

            prev = s
        
        S_part_list.append(S[memo:])


        # print(S_part_list)

        def sum_maker(part_of_S_list):

            if len(part_of_S_list) >=2:
                num_list = [0]

                for s in part_of_S_list:
                    if s == '<':
                        num_list.append(num_list[-1] + 1)
                    else:
                        num_list.append(num_list[-1] - 1)
                
                min_num = min(num_list)
                num_list = np.array(num_list)
                num_list -= min_num

                if part_of_S_list[0] == '<':
                    num_list[0] = 0

                if part_of_S_list[-1] == '>':
                    num_list[-1] = 0

                for j, s in enumerate(part_of_S_list[::-1]):
                    if s == '>' and j > 0:
                        num_list[-1*(j+1)] = num_list[-1*(j)] + 1


                # print(num_list)
                res = sum(num_list)
                # print(res)
            else:
                res = 1

            return res

        res = 0
        # print(S_part_list)
        for s_part in S_part_list:
            # print(s_part)
            res += sum_maker(s_part)

    else:
        res = 1
    
    print(res)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
cnt = [[0, 0] for i in range(len(s) + 1)]
ans = 0
for i in range(len(s)):
    if s[i] == '<':
        cnt[i + 1][0] += 1
    else:
        cnt[i][1] += 1
for i in range(1, len(s)):
    if cnt[i - 1][1] == 0:
        cnt[i][0] += cnt[i - 1][0]
    if cnt[len(s) - i][0] == 0:
        cnt[len(s) - i - 1][1] += cnt[len(s) - i][1]
for i in range(len(s) + 1):
    ans += max(cnt[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
cnt = [[0, 0] for i in range(len(s))]
ans = 0
for i in range(len(s)):
    if s[i] == '<':
        cnt[i][0] += 1
    else:
        cnt[i][1] += 1
for i in range(1, len(s)):
    if cnt[i - 1][1] == 0:
        cnt[i][0] += cnt[i - 1][0]
    if cnt[len(s) - i][0] == 0:
        cnt[len(s) - i - 1][1] += cnt[len(s) - i][1]
    if s[i - 1] != s[i]:
        ans -= 1
for i in range(len(s)):
    ans += max(cnt[i])
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) + 1
ans = 0
l = 0
r = 0
if s[0] == ">":
    p = 0
elif s[0] == "<":
    p = 1
for i in range(n-1):
    if p == 0:
        if s[i] == ">":
            l += 1
        elif s[i] == "<":
            p = 1
            ans += l*(l+1)//2
            if l < r:
                ans -= l
            elif l >= r:
                ans -= r 
            l = 0
            r = 1
    elif p == 1:
        if s[i] == "<":
            r += 1
        elif s[i] == ">":
            l += 1
            p = 0
            ans += r*(r+1)//2
if r != 0:
    ans += r*(r+1)//2

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
total = 0
if s[0] == '<':
    status = 'pos'
    v = 0
    c_neg = 0
else:
    status = 'neg'
    c_neg = 1
    v = 0
i = 1
while i < len(s):
    if s[i] == '<':
        if status == 'neg':
            total += int(c_neg*(c_neg+1))/2
            total -= min(v,c_neg)
            #c_neg = 0
            v = 1
            total += v
            status = 'pos'
        else:
            v += 1
            total += v
    else:
        if status == 'pos':
            #total -= v
            status = 'neg'
            c_neg = 1
        else:
            c_neg += 1
    i += 1
#終了処理
if status == 'neg':
    total += int(c_neg*(c_neg+1))/2
    total -= min(v,c_neg)
            
if len(s) == 1:
    total = 1
print(int(total))

Submission status: Wrong Answer

Solution code:
s = input()
total = 0
if s[0] == '<':
    status = 'pos'
    v = 0
    c_neg = 0
else:
    status = 'neg'
    c_neg = 1
    v = 0
i = 1
while i < len(s):
    if s[i] == '<':
        if status == 'neg':
            total += int(c_neg*(c_neg+1))/2
            total -= min(v,c_neg)
            #c_neg = 0
            v = 1
            total += v
            status = 'pos'
        else:
            v += 1
            total += v
    else:
        if status == 'pos':
            #total -= v
            status = 'neg'
            c_neg = 1
        else:
            c_neg += 1
    i += 1
#終了処理
if status == 'neg':
    total += int(c_neg*(c_neg+1))/2
            
            
if len(s) == 1:
    total = 1
print(int(total))

Submission status: Wrong Answer

Solution code:
n =input()
a=n.count("<")
b =n.count(">")

c = a+b

print(int((c-1)*c/2))

Submission status: Wrong Answer

Solution code:
n =input()
a=n.count("<")
b =n.count(">")

c = a+b

print((c-1)*c/2)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
inc_cnt = 0
dec_cnt = 0
prev = ""
for a in s:
    if prev+a == "><":
        inc_cnt = 0
        dec_cnt = 0
    if a == '<':
        inc_cnt += 1
        ans += inc_cnt
    else:
        dec_cnt += 1
        if dec_cnt-1 < inc_cnt:
            ans += dec_cnt-1
        else:
            ans += dec_cnt-1+inc_cnt
    prev = a
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
c = [0, 0]
n = 0
s = ""
for i in range(len(S)):
  if s == "":
    s = S[i]
    n = 1
  elif s == S[i]:
    n += 1
  else:
    if n > 1:
      if S[i] == "<": c[0] += n
      else: c[1] += n
    n = 1
    s = S[i]

if n > 1:
  if S[i] == "<": c[0] += n
  else: c[1] += n
c = max(c)
ans = c * (c+1) // 2

import math
if c == 0:
  ans = math.ceil(len(S)/2) 
  
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
c = [0, 0]
n = 0
s = ""
for i in range(len(S)):
  if s == "":
    s = S[i]
    n = 1
  elif s == S[i]:
    n += 1
  else:
    if n > 1:
      if S[i] == "<": c[0] += n
      else: c[1] += n
    n = 1
    s = S[i]

if n > 1:
  if S[i] == "<": c[0] += n
  else: c[1] += n
c = max(c)
print(c * (c + 1) // 2)

Submission status: Wrong Answer

Solution code:
from itertools import*
s=input()


x=[len(list(v)) for k,v in groupby(s)]

n=len(x)

ans=0
if s[0]=="<":
    ans+=(x[0]-1)*x[0]//2
    n-=1
    del x[0]
if s[-1]==">":
    ans+=(x[-1]-1)*x[-1]//2
    n-=1
for i in range(0,n,2):
    ma=max(x[i],x[i+1])
    mi=min(x[i],x[i+1])
    ans+=ma*(ma+1)//2
    ans+=(mi-1)*mi//2
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
if S[0] == "<":
  a = S.count(">")
else:
  a = S.count("<")
print(a * (a + 1) // 2)

Submission status: Wrong Answer

Solution code:
S = input()
a = S.count(">")
print(a * (a + 1) // 2)

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)
L,R=[0],[0]
for s in S:
    if s == '<': L.append(L[-1]+1)
    else: L.append(0)
for s in S[::-1]:
    if s == '>': R.append(R[-1]+1)
    else: R.append(0)
ans = 0
for i in range(N):
    ans += max(L[i+1], R[-2-i])
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
f = [0]*(N+1)
cnt = 0
for i in range(N):
    if S[i] == '<':
        cnt += 1
        f[i+1] = cnt
    else:
        cnt = 0
        f[i+1] = 0
g = [0]*(N+1)
for i in range(N):
    if S[-i-1] == '>':
        cnt += 1
        g[N-i-1] = cnt
    else:
        cnt = 0
        g[N-i-1] = cnt
ans = 0
for i in range(N+1):
    print(max(f[i], g[i]))
    ans += max(f[i], g[i])
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)+1
l=[0]*N
for i in range(N-1):
    if S[i]=="<":
        l[i+1]=l[i]+1
print(l)
for i in range(N-2,-1,-1):
    if S[i]==">":
        l[i]=max(l[i+1]+1,l[i])
print(sum(l))
print(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)+1
cur = [0]*(n)
temp = 0
for i in range(len(s)):
    if s[len(s)-2-i] == '>':
        if s[len(s)-i-1] == '<':
            cur[len(s)-i-1] = 0
        else:
            temp += 1
            cur[len(s)-i-1] = temp
    else:
        if s[len(s)-i-1] == '>':
            temp += 1
            cur[len(s)-i-1] = temp
            temp = 0
for i in range(len(s)):
    if s[i] == '<':
        if i != 0 and s[i-1] == '<':
            cur[i+1] = cur[i]+1
        elif i != 0 and s[i-1] == '>':
            cur[i+1] = max(cur[i]+1, cur[i+1])
        else:
            cur[i+1] = max(cur[i]+1,cur[i+1])
    else:
        if i != 0 and s[i-1] == '<':
            cur[i+1] = min(cur[i+1], cur[i]-1)
        elif i != 0 and s[i-1] == '>':
            None
        else:
            None
print(sum(cur))

Submission status: Wrong Answer

Solution code:
import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
 
#########################
# imgur.com/Pkt7iIf.png #
#########################
 
def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r
 
def divs(n, start=1):
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors
 
def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
 
def flin(d, x, default=-1):
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return (default, default)
    else:
        return (left, right)
 
def ceil(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def prr(a, sep=' '): print(sep.join(map(str, a)))
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
 
 
# region fastio
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
	newlines = 0
 
	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = "x" in file.mode or "r" not in file.mode
		self.write = self.buffer.write if self.writable else None
 
	def read(self):
			while True:
					b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
					if not b:
							break
					ptr = self.buffer.tell()
					self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
			self.newlines = 0
			return self.buffer.read()
 
	def readline(self):
			while self.newlines == 0:
					b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
					self.newlines = b.count(b"\n") + (not b)
					ptr = self.buffer.tell()
					self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
			self.newlines -= 1
			return self.buffer.readline()
 
	def flush(self):
			if self.writable:
					os.write(self._fd, self.buffer.getvalue())
					self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
	def __init__(self, file):
			self.buffer = FastIO(file)
			self.flush = self.buffer.flush
			self.writable = self.buffer.writable
			self.write = lambda s: self.buffer.write(s.encode("ascii"))
			self.read = lambda: self.buffer.read().decode("ascii")
			self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
'''for _ in range(ii()):
    n=ii()
    a=li()
    m,k,md=0,0,0
    mn,mx=10**9+1,-10**9-1
    for i in range(n-1):
        if a[i]!=-1 and a[i+1]!=-1:
            m=max(m,abs(a[i]-a[i+1]))
    for i in range(1,n-1):
        if a[i]==-1:
            if a[i+1]!=-1:
                mn=min(mn,a[i+1])
                mx=max(mx,a[i+1])
            if a[i-1]!=-1:
                mn=min(mn,a[i-1])
                mx=max(mx,a[i-1])
    if mn==10**9+1 and mx==-10**9-1:
        print(0,0,sep=' ')
    else:
        md=(mn+mx+1)//2
        m=max(abs(mx-md),abs(mn-md),m)
        print(m,md,sep=' ')'''

'''for _ in range(ii()):
    n,m=mi()
    tg=n//2
    n0=n-m
    total=(n*(n+1))//2
    res=0
    if n0<n:
        if m>=tg:
            res=total-n0
        else:
            i=tg-m
            if n&1:
                nn0=2*i+1
            else:
                nn0=2*i
            res=total-((nn0*(nn0+1))//2)-(n0-nn0)
            #print(nn0,n0-nn0)
    print(res)'''
#***************************************************************************************************************************


'''def solve():
    n=int(input())
    a=list(map(int,input().split()))
    diff=len(set(a))
    if diff==1: print (int((n*(n+1))/2))
    elif diff==n: print (1)
    else:
        i=j=ans=0
        ahead=True
        distinct={}
        while j<n:
            if ahead:
                distinct[a[j]]=distinct[a[j]]+1 if a[j] in distinct else 1
                if len(distinct)==diff:
                    ahead=False
                else:
                    j+=1
            else:
                ans+=n-j
                if distinct[a[i]]>1:
                    distinct[a[i]]-=1
                else:
                    distinct.pop(a[i])
                    j+=1
                    ahead=True
                i+=1
        print (ans)
 
solve()'''

#******************************************************************************************

s=input()
n=len(s)
i,cntl,cntg=0,0,0
res,fl,fg=0,0,0
while(i<n):
    if s[i]=='<':
        while(i<n and s[i]!='>'):
            fl=1
            cntl+=1
            i+=1
    else:
        while(i<n and s[i]!='<'):
            fg=1
            cntg+=1
            i+=1
    if fl==1 and fg==1:
        res+=max(cntl,cntg)
        cntl-=1
        cntg-=1
        res+=cntl*(cntl+1)//2
        res+=cntg*(cntg+1)//2
        fl,fg,cntl,cntg=0,0,0,0
if fl:
    res+=cntl*(cntl+1)//2
if fg:
    res+=cntg*(cntg+1)//2
print(res)

Submission status: Wrong Answer

Solution code:
S=list(input())

s=0
f=0
g=0
h=0
for i in range(len(S)):
    if S[i]==">":
        g=0
        f+=1
        if f!=1:
            if h>=f:
                s+=f-1
            else:
                s+=f
        
    else:
        f=0
        g+=1
        s+=g
        h=g

print(s)

Submission status: Wrong Answer

Solution code:
S=list(input())

s=0
f=0
g=0
h=0
for i in range(len(S)):
    if S[i]==">":
        g=0
        f+=1
        if f!=1:
            if h>=f:
                s+=f-1
            else:
                s+=f-1+h
        
    else:
        f=0
        g+=1
        s+=g
        h=g

print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
flag = 0 # ">"=1 "<" = 0
x = s[0]
r = 0 #"<"
l = 0 #">"

if x==">":
    flag = 1
    l += 1
else:
    r += 1

for i in range(1,len(s)):
    if s[i]==x:
        if flag==1:
            l += 1
        else:
            r += 1
    else:
        if flag==1:
            ans += sum(range(max(r,l)+1)) + sum(range(min(r,l)))
            l = 0
            r = 1
            x = s[i]
            flag = 0
        else:
            x = s[i]
            l += 1
            flag = 1
    print(i,r,l,ans)
ans += sum(range(max(r,l)+1)) + sum(range(min(r,l)))
print(ans)

Submission status: Wrong Answer

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

# 左から探索
for i in range(len(S)):
  if S[i]=='<':
    res[i+1]=res[i]+1
    
for i in range(len(S)-1,0,-1):
  if S[i]=='>':
    res[i]=max(res[i],res[i+1]+1)
    
print(sum(res))

Submission status: Wrong Answer

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

# 左から探索
for i in range(len(S)):
  if S[i]=='<':
    res[i+1]=res[i]+1
    
for i in range(len(S)-1,0,-1):
  if S[i]=='>':
    res[i]=max(res[i],res[i+1]+1)
    
print(res)
print(sum(res))

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

S = input()
N = len(S) + 1

v = []
last = S[0]
cnt = 0
for c in S:
    if c == last:
        cnt += 1
    else:
        v.append(cnt if last == '<' else -cnt)
        last = c
        cnt = 1
v.append(cnt if last == '<' else -cnt)


ans = 0
for i, c in enumerate(v):
    if c > 0:
        if i < len(v) - 1 and c + v[i + 1] < 0:
            c -= 1
    else:
        if i > 0 and v[i - 1] > -c:
            c += 1
        c = -c
    ans += c * (c + 1) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)
L=[0]*(N+1)
for i in range(len(S)):
    if S[i]=="<":
        L[i+1]+=L[i]+1

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

Submission status: Wrong Answer

Solution code:
s=list(input())
n=len(s)+1
l=[0]*n

for i in range(n-1):
  if s[i]=='<':
    l[i+1]=l[i]+1
  else:
    l[i+1]=l[i]-1
    
p=min(l)
ans=0
for i in range(n):
  l[i]-=p
  ans+=l[i]
  
print(ans)

Submission status: Wrong Answer

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

ans1 = 0
right = 0
count = 0
for i in range(n-1):
	if s[i] == '<':
		count = 0
		ans1 += right + 1
		right += 1
	else:
		count += 1
		if right == 0:
			ans1 += count
		else:
			ans1 += right-1
			right -= 1
if right != 0:
	i = n-2
	while s[i] == '>':
		ans1 -= right
		i -= 1

ans2 = 0
left = 0
count = 0
for i in reversed(range(n-1)):
	if s[i] == '>':
		count = 0
		ans2 += left + 1
		left += 1
	else:
		count += 1
		if left == 0:
			ans2 += count
		else:
			ans2 += left-1
			left -= 1

if left != 0:
	i = 0
	while s[i] == '<':
		ans2 -= left
		i += 1

print(min(ans1,ans2))

Submission status: Wrong Answer

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

ans1 = 0
right = 0
count = 0
for i in range(n-1):
	if s[i] == '<':
		count = 0
		ans1 += right + 1
		right += 1
	else:
		count += 1
		if right == 0:
			ans1 += count
		else:
			ans1 += right-1
			right -= 1
if right != 0 and s[n-2] == '>':
	ans1 -= right

ans2 = 0
left = 0
count = 0
for i in reversed(range(n-1)):
	if s[i] == '>':
		count = 0
		ans2 += left + 1
		left += 1
	else:
		count += 1
		if left == 0:
			ans2 += count
		else:
			ans2 += left-1
			left -= 1
if left != 0 and s[0] == '<':
	ans2 -= left

print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
s = str(input())
num = [0 for _ in range(len(s)+1)]
for i in range(len(s)):
  if (s[i] == "<"):
    num[i+1] = num[i]+1
for i in range(len(s),1,-1):
  if (s[i-1] == ">"):
    num[i-1] = max(num[i-1],num[i]+1)
print(sum(num))

Submission status: Wrong Answer

Solution code:
s = str(input())
num = [0 for _ in range(len(s)+1)]
for i in range(len(s)):
  if (s[i] == "<"):
    num[i+1] = num[i]+1
for i in range(len(s),1,-1):
  if (s[i-1] == ">"):
    num[i-1] == max(num[i-1],num[i]+1)
print(sum(num))

Submission status: Wrong Answer

Solution code:
s = str(input())
count = 0
for i in range(len(s)):
    if(s[i] == ">"):
        count += 1
ans = 0
for i in range(1,count+1):
    ans += i
print(ans)

Submission status: Wrong Answer

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

s = str(input())
n = len(s) + 1
arrk = []
arrg = []
tmp = s[0]
cnt = 1
for i in range(1, n-1):
    if s[i] == tmp:
        cnt += 1
    elif s[i] != tmp:
        if tmp == '<':
            arrk.append(cnt)
        else:
            arrg.append(cnt)
        cnt = 1
        tmp = s[i]
if tmp == '<':
    arrk.append(cnt)
else:
    arrg.append(cnt)
#print(arrk, arrg)
ans = 0
for i in range(len(arrk)):
    #print(calcsum(arrk[i]-1))
    ans += calcsum(arrk[i]-1)
for i in range(len(arrg)):
    #print(calcsum(arrg[i]-1))
    ans += calcsum(arrg[i]-1)
print('ans',ans)
l = min(len(arrg), len(arrk))
m = max(len(arrg), len(arrk))
#print(l, len(arrg), len(arrk))
if s[0] == '<':
    for i in range(l):
        ans += max(arrg[i], arrk[i])
    if l < len(arrk):
        ans += arrk[len(arrk) - 1]
elif s[0] == '>':
    ans += arrg[0]
    #print(arrg[0])
    if l != m:
        for i in range(l):
            #print('a', arrg[i+1], arrk[i], max(arrg[i+1], arrk[i]))
            ans += max(arrg[i+1], arrk[i])
    else:
        for i in range(l-1):
            #print('a', arrg[i+1], arrk[i], max(arrg[i+1], arrk[i]))
            ans += max(arrg[i+1], arrk[i])
    if s[n-2] == '<':
        ans += arrk[len(arrk) - 1]
    if l < len(arrk):
        ans += arrk[len(arrk) - 1]
print(ans)

Submission status: Wrong Answer

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

s = str(input())
n = len(s) + 1
arrk = []
arrg = []
tmp = s[0]
cnt = 1
for i in range(1, n-1):
    if s[i] == tmp:
        cnt += 1
    elif s[i] != tmp:
        if tmp == '<':
            arrk.append(cnt)
        else:
            arrg.append(cnt)
        cnt = 1
        tmp = s[i]
if tmp == '<':
    arrk.append(cnt)
else:
    arrg.append(cnt)
#print(arrk, arrg)
ans = 0
for i in range(len(arrk)):
    #print(calcsum(arrk[i]-1))
    ans += calcsum(arrk[i]-1)
for i in range(len(arrg)):
    #print(calcsum(arrg[i]-1))
    ans += calcsum(arrg[i]-1)
#print('ans',ans)
l = min(len(arrg), len(arrk))
#print(l, len(arrg), len(arrk))
if s[0] == '<':
    for i in range(l):
        ans += max(arrg[i], arrk[i])
    if l < len(arrk):
        ans += arrk[len(arrk) - 1]
elif s[0] == '>':
    ans += arrg[0]
    #print(arrg[0])
    for i in range(l-1):
        #print('a',max(arrg[i+1], arrk[i]))
        ans += max(arrg[i+1], arrk[i])
    '''
    if s[n-2] == '<':
        ans += arrk[len(arrk) - 1]
    '''
print(ans)

Submission status: Wrong Answer

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

s = str(input())
n = len(s) + 1
arrk = []
arrg = []
tmp = s[0]
cnt = 1
for i in range(1, n-1):
    if s[i] == tmp:
        cnt += 1
    elif s[i] != tmp:
        if tmp == '<':
            arrk.append(cnt)
        else:
            arrg.append(cnt)
        cnt = 1
        tmp = s[i]
if tmp == '<':
    arrk.append(cnt)
else:
    arrg.append(cnt)
#print(arrk, arrg)
ans = 0
for i in range(len(arrk)):
    #print(calcsum(arrk[i]-1))
    ans += calcsum(arrk[i]-1)
for i in range(len(arrg)):
    #print(calcsum(arrg[i]-1))
    ans += calcsum(arrg[i]-1)
#print('ans',ans)
l = min(len(arrg), len(arrk))
#print(l, len(arrg), len(arrk))
if s[0] == '<':
    for i in range(l):
        ans += max(arrg[i], arrk[i])
    if l < len(arrk):
        ans += arrk[len(arrk) - 1]
elif s[0] == '>':
    ans += arrg[0]
    #print(arrg[0])
    for i in range(l-1):
        #print('a',max(arrg[i+1], arrk[i]))
        ans += max(arrg[i+1], arrk[i])
    if s[n-2] == '<':
        ans += arrk[len(arrk) - 1]
print(ans)