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=list(input())
l=len(s)
ans=0

if len(set(s))==1:
    for i in range(1,l+1):
        ans+=i
    print(ans)
    exit()

for i in range(l-1):
    if s[i]=="<" and s[i+1]==">":
        left=1
        right=1
        for j in range(i):
            if s[i-j-1]=="<":
                left+=1
            else:
                break
        for j in range(l-i-2):
            if s[i+j+2]==">":
                right+=1
            else:
                break
        p=max(left,right)
        q=min(left,right)
        for j in range(p):
            ans+=(j+1)
        for j in range(q-1):
            ans+=(j+1)
if s[0]==">":
    ans+=1
    for i in range(1,l):
        if s[i]==">":
            ans+=(i+1)
        else:
            break
if s[-1]=="<":
    ans+=1
    for i in range(2,l+1,-1):
        if s[-i]=="<":
            ans+=i
        else:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
l=len(s)
ans=0
for i in range(l-1):
    if s[i]=="<" and s[i+1]==">":
        left=1
        right=1
        for j in range(i):
            if s[i-j-1]=="<":
                left+=1
            else:
                break
        for j in range(l-i-2):
            if s[i+j+2]==">":
                right+=1
            else:
                break
        p=max(left,right)
        q=min(left,right)
        for j in range(p):
            ans+=(j+1)
        for j in range(q-1):
            ans+=(j+1)
if s[0]==">":
    ans+=1
    for i in range(1,l):
        if s[i]==">":
            ans+=(i+1)
        else:
            break
if s[-1]=="<":
    ans+=1
    for i in range(2,l+1,-1):
        if s[-i]=="<":
            ans+=i
        else:
            break

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
count_more = 0
count_less = 0
ans = 0
pre_si = '>'
for i, si in enumerate(S):
    if pre_si == '>' and si == '<':
        max_n = max(count_more, count_less)
        min_n = min(count_more, count_less)
        ans += (max_n+1)*(max_n)//2
        ans += (min_n)*(min_n-1)//2
        count_more = 0
        count_less = 0
    if si == '<':
        count_more += 1
    elif si == '>':
        count_less += 1
    pre_si = si
max_n = max(count_more, count_less)
min_n = min(count_more, count_less)
ans += (max_n+1)*(max_n)//2
ans += (min_n)*(max_n-1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
#><となるところを見つける<<となるところを見つける>>となるところを見つける<>となるところについて考える
n=len(s)
ans=[0]*(n+1)
if s[0]=='<':
    ans[0]=0
if s[n-1]=='>':
    ans[n]=0
for i in range(n-2):
    if s[i]=='>' and s[i+1]=='<':
        ans[i+1]=0

#左から>>となる部分を探す
for i in range(n):
    if s[i]=='<':
        ans[i+1]=max(ans[i+1],ans[i]+1)
for i in range(n-1,0,-1):
    if s[i]=='>':
        ans[i]=max(ans[i],ans[i+1]+1)
print(sum(ans))

Submission status: Wrong Answer

Solution code:
s = input()

cnt = 0
ans = 0
tmp = 0
check = 0
for x in s:
    cnt += 1
    if x == '<':
        tmp += 1
        if check != cnt - 1:
            tmp = 0
        ans += tmp
        check = cnt
    else:
        tmp -= 1
        ans += tmp
        if tmp < 0:
            ans += (cnt -  check + 1)
            tmp += 1

print(ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
k=0
bef="x"
n=[]
ans=0
def kai(n):
  if n==0:
    return 0
  ret=0
  for i in range(1,n+1):
    ret+=i
  return ret

for i in s:
  if bef!=i:
    if bef=="x":
      st=i
      bef=i
      k+=1
      continue
    bef=i
    n.append(k)
    k=0
  k+=1
n.append(k)
n.reverse()

while len(n)!=0:
  if len(n)==1:
    ans+=kai(n.pop())
  else:
    f=n.pop()
    s=n.pop()
    if f>s:
      ans+=kai(f)+kai(s-1)
    else:
      ans+=kai(f-1)+kai(s)
    #print("{} {}".format(f,s))

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools as it
s = input()
n = len(s)
a = [0]*(n+1)
for i in range(n):
  if s[i] == "<":
    a[i+1] = +1
  if s[i] == ">":
    a[i+1] = -1
l = [0]*(n+1)
for i in range(n):
  if i < n-1:
    if s[i] == ">" and s[i+1] == "<":
      l[i+1] = 0
    else:
      l[i+1] += l[i] + a[i+1]
  else:
    l[i+1] += l[i] + a[i+1]
m = min(l)
r = [i + abs(m) for i in l]
print(sum(r))

Submission status: Wrong Answer

Solution code:
# 解説動画視聴

s = input()

a = [0]*(len(s)+1)

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

print(sum(a))

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
L_cnt = 0
R_cnt = 0

for i in range(len(s)+1):
    j = i-1
    if 0 < i < len(s):
        while s[i] == '>':
            R_cnt += 1
            i += 1
            if len(s)-1 < i:
                break
    if j < len(s):
        while s[j] == '<' and 0 <= j:
            L_cnt += 1
            j -= 1

    ans += max(L_cnt,R_cnt)
    L_cnt = 0
    R_cnt = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy
a = [x for x in range(5*(10**5)+1)]
b = numpy.cumsum(a) #累積和

s = input()

ans = 0
num = 0
if s[0] == '<':
    ans = 0
    num = 1
else:
    ans = 1
    num = 1

befor_s = s[0]

cnt = 0

for i in range(1,len(s)):
    if s[i-1] == '<' and s[i] == '<': 
        num += 1
    elif s[i-1] == '<' and s[i] == '>':
        cnt += 1
        ans += b[num-1]


    elif s[i-1] == '>' and s[i] == '<':
        if num < cnt:
            ans += b[cnt]
        else:
            ans += b[cnt-1] + num
        cnt = 0
        num = 1
    else:
        cnt += 1
if s[len(s)-2] == '<' and s[len(s)-1] == '<':
    ans += b[num]
elif s[len(s)-2] == '<' and s[len(s)-1] == '>':
    ans += num
elif s[len(s)-2] == '>' and s[len(s)-1] == '<':
    ans += 1
else:
    if num < cnt:
        ans += b[cnt]
    else:
        ans += num + b[cnt-1]
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy
a = [x for x in range(5*(10**5)+1)]
b = numpy.cumsum(a) #累積和

s = input()

ans = 0
num = 0
if s[0] == '<':
    ans = 0
    num = 1
else:
    ans = 1
    num = 1

befor_s = s[0]

cnt = 0

for i in range(1,len(s)):
    if s[i-1] == '<' and s[i] == '<': 
        num += 1
    elif s[i-1] == '<' and s[i] == '>':
        cnt += 1
        ans += b[num-1]


    elif s[i-1] == '>' and s[i] == '<':
        if num < cnt:
            ans += b[cnt]
        else:
            ans += b[cnt-1] + num
        cnt = 0
        num = 1
    else:
        cnt += 1
if s[len(s)-2] == '<' and s[len(s)-1] == '<':
    ans += b[num]
elif s[len(s)-2] == '<' and s[len(s)-1] == '>':
    ans += num
elif s[len(s)-2] == '>' and s[len(s)-1] == '<':
    ans += 1
else:
    if num < cnt:
        ans += b[cnt]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = s()
n = len(S)
num = 1
num2 = 1
ans = 0
Flag = 0

for i in range(n-1):
    if S[i] == S[i+1]:
        ans += num
        num += 1
    if S[i] == "<" and S[i+1] == ">":
        num2 = num
        num = 1
        Flag = 1
    if S[i] == ">" and S[i+1] == "<":
        ans += max(num,num2)
        num = 1
        Flag = 0

if Flag:
    ans += max(num,num2)
else:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

count0, count1 = 0, 0
val = []
for i in range(len(S)):
    if S[i] == '<':
        count0 += 1
        if count1 != 0:
            val.append(count1)
        if i == len(S)-1:
            val.append(count0)
        count1 = 0
    else:
        count1 += 1
        if count0 != 0:
            val.append(count0)
        if i == len(S)-1:
            val.append(count1)
        count0 = 0
ans = 0
if len(val) != 1:
    if S[0] == '>' and val[0] == 1:
        ans += 1
    for i in range(0, len(val)-1, 2):
        a = max(val[i], val[i+1])
        b = min(val[i], val[i+1])
        ans += a*(a+1)/2 + (b-1)*b/2
    if len(val) % 2 == 1:
        if S[-1] == '>':
            a = max(val[-2], val[-1])
            ans += a*(a+1)/2
        else:
            b = min(val[-2], val[-1])
            ans += (b+1)*b/2    
else:
    ans += (val[0]+1)*val[0]/2
        
print(int(ans))

Submission status: Wrong Answer

Solution code:
S = input()

count0, count1 = 0, 0
val = []
for i in range(len(S)):
    if S[i] == '<':
        count0 += 1
        if count1 != 0:
            val.append(count1)
        if i == len(S)-1:
            val.append(count0)
        count1 = 0
    else:
        count1 += 1
        if count0 != 0:
            val.append(count0)
        if i == len(S)-1:
            val.append(count1)
        count0 = 0

ans = 0
for i in range(0, len(val)-1, 2):
    a = max(val[i], val[i+1])
    b = min(val[i], val[i+1])
    ans += a*(a+1)/2 + (b-1)*b/2
if len(val) % 2 == 1:
    print(int(ans)+1)
else:
    print(int(ans))

Submission status: Wrong Answer

Solution code:
S = input()

count0, count1 = 0, 0
val = []
first = '-'
for i in range(len(S)):
    if S[i] == '<' and i == 0:
        first = 'right'
    elif S[i] == '>' and i == 0:
        first == 'left'
        
    if S[i] == '<':
        count0 += 1
        if count1 != 0:
            val.append(count1)
        if i == len(S)-1:
            val.append(count0)
        count1 = 0
    else:
        count1 += 1
        if count0 != 0:
            val.append(count0)
        if i == len(S)-1:
            val.append(count1)
        count0 = 0

ans = 0
for i in range(0, len(val)-1, 2):
    a = max(val[i], val[i+1])
    b = min(val[i], val[i+1])
    ans += a*(a+1)/2 + (b-1)*b/2
if first == 'right':
    print(int(ans)+1)
else:
    print(int(ans))

Submission status: Wrong Answer

Solution code:
s = str(input())
ans = 0
def leftmore(ln):
    ret = [0]
    cur = 0
    for c in ln:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    return ret

def rightless(ln):
    revl = reversed(ln)
    ret = [0]
    cur = 0
    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        ret.append(cur)
    return list(reversed(ret))

lm = leftmore(s)
rl = rightless(s)
print(lm)
print(rl)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
c=1#連続数
temp=0
for i in range(len(s)):
    if i==0:
        ans+=1
    else:
        if s[i]==">" and s[i]==s[i-1]:
            c+=1
            if temp>c:
                ans+=c-1
            else:
                ans+=c
        elif s[i]==">" and s[i]!=s[i-1]:
            temp=c
            c=1
        elif s[i]=="<" and s[i]==s[i-1]:
            c+=1
            ans+=c
        elif s[i]=="<" and s[i]!=s[i-1]:
            c=1
            tmp=0
            ans+=1
    #print(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
c=1#連続数
temp=0
for i in range(len(s)):
    if i==0:
        ans+=1
    else:
        if s[i]==">" and s[i]==s[i-1]:
            c+=1
            if temp>c:
                ans+=c-1
            else:
                ans+=c
        elif s[i]==">" and s[i]!=s[i-1]:
            temp=c
            c=1
        elif s[i]=="<" and s[i]==s[i-1]:
            c+=1
            ans+=c
        elif s[i]=="<" and s[i]!=s[i-1]:
            c=1
            ans+=1
    #print(ans)
print(ans)

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

l = len(S)
x = [0]*(l+3)
y = [0]*(l+3)
for i in range(l):
    if S[i] == "<":
        x[i+1] = x[i]+1
for i in range(l):
    if S[i] == ">":
        y[l-i+1] = y[l-i+2]+1


res = 0
for i in range(l+1):
    res += max(x[i], y[i+2])
print(res)

Submission status: Wrong Answer

Solution code:
s = list(input())
ans = [0]
for c in s:
    if c == ">":
        ans.append(ans[-1]-1)
    if c == "<":
        ans.append(ans[-1]+1)

print(ans)
print(sum(ans))
m = min(ans)
if min(ans) >= 0:
    print(sum(ans))
else:
    print(sum(ans)-m*(len(ans)-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

S = ('<' if S[0] == '>' else '>') + S \
    + ('<' if S[-1] == '>' else '>') # 最初と最後にダミー追加、長さn+1
print(S)
for i in range(n):
    if S[i : i + 2] == '><': # 極小値
        for j in range(i, 0, -1):   # 左に辿る
            if S[j] == '<': break
            a[j - 1] = max(a[j - 1], a[j] + 1)
        for j in range(i + 1, n):   # 右に辿る
            if S[j] == '>': break
            a[j] = max(a[j], a[j - 1] + 1)

print(sum(a))

Submission status: Wrong Answer

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

S = ('<' if S[0] == '>' else '<') + S \
    + ('<' if S[-1] == '>' else '<') # 最初と最後にダミー追加、長さn+1

for i in range(n):
    if S[i : i + 2] == '><': # 極小値
        for j in range(i, 0, -1):   # 左に辿る
            if S[j] == '<': break
            a[j - 1] = max(a[j - 1], a[j] + 1)
        for j in range(i + 1, n):   # 右に辿る
            if S[j] == '>': break
            a[j] = max(a[j], a[j - 1] + 1)

print(sum(a))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

S = S()

data = []

prev = ">"
count = 0
for s in S:
  if s == prev:
    count += 1
  else:
    data.append(count)
    count = 1
  prev = s
data.append(count)
if S[0] == ">":
  data.append(0)
  
ans = sum(d*(d+1)//2 for d in data)

N = (len(data)-2)//2
gosa = sum(min(data[i*2+1],data[i*2+2]) for i in range(N))

print(ans-gosa)

Submission status: Wrong Answer

Solution code:
s=str(input())
s=list(s)
temp=[0]*(len(s)+1)
cnt=0
ans=0
for i in range(len(s)):
  if s[i]=="<":
    if temp[i]<0:
      ans=ans+abs(cnt*temp[i])
      temp[i+1]=1
    else:
      temp[i+1]=temp[i]+1
    if temp[i]>0:
      cnt=0
    else:
      cnt=1
  else:
    if temp[i]>0:
      temp[i+1]=0
    else:
      temp[i+1]=temp[i]-1
    cnt=cnt+1
if temp[len(s)]<0:
  ans=ans+abs(cnt*temp[len(s)])
ans=0
for i in range(len(temp)):
  ans=ans+abs(temp[i])
print(ans)

Submission status: Wrong Answer

Solution code:
s=str(input())
s=list(s)
temp=[0]*(len(s)+1)
cnt=0
ans=0
for i in range(len(s)):
  if s[i]=="<":
    if temp[i]<0:
      ans=ans+abs(cnt*temp[i])
      temp[i+1]=1
    else:
      temp[i+1]=temp[i]+1
    if temp[i]>0:
      cnt=0
    else:
      cnt=1
  else:
    if temp[i]>0:
      temp[i+1]=0
    else:
      temp[i+1]=temp[i]-1
    cnt=cnt+1
if temp[len(s)]<0:
  ans=ans+abs(cnt*temp[len(s)])
print(sum(temp)+ans)

Submission status: Wrong Answer

Solution code:
s=str(input())
s=list(s)
temp=[0]*(len(s)+1)
cnt=0
ans=0
for i in range(len(s)):
  if s[i]=="<":
    if temp[i]<0:
      ans=ans+abs(cnt*temp[i])
      temp[i+1]=1
      print(temp,i,cnt,temp[i])
    else:
      temp[i+1]=temp[i]+1
    if temp[i]>0:
      cnt=0
    else:
      cnt=1
  else:
    if temp[i]>0:
      temp[i+1]=0
    else:
      temp[i+1]=temp[i]-1
    cnt=cnt+1
if temp[len(s)]<0:
  ans=ans+abs(cnt*temp[len(s)])
print(sum(temp)+ans)

Submission status: Wrong Answer

Solution code:
s=str(input())
s=list(s)
temp=[0]*(len(s)+1)
cnt=0
ans=0
for i in range(len(s)):
  if s[i]=="<":
    if temp[i]<0:
      ans=ans+abs(cnt*temp[i])
      temp[i+1]=1
    else:
      temp[i+1]=temp[i]+1
    if temp[i]>0:
      cnt=0
    else:
      cnt=1
  else:
    if temp[i]>0:
      temp[i+1]=0
    else:
      temp[i+1]=temp[i]-1
    cnt=cnt+1
print(sum(temp)+ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
num = 0
n = len(s)
l = []
i = 0
while i < n:
  if s[i] == '<':
    l.append(num)
    num+=1
    i+=1
    if i==n:
      l.append(num)
  else:
    cur = 1
    while i < n and s[i]=='>':
      l.append(cur)
      i+=1
      cur+=1
    num = 0
print(sum(l))

Submission status: Wrong Answer

Solution code:
s = list(input())
num = 0
n = len(s)
l = []
i = 0
while i < n:
  if s[i] == '<':
    l.append(num)
    num+=1
    i+=1
    if i==n:
      l.append(num)
  else:
    cur = 0
    while i < n and s[i]=='>':
      l.append(cur)
      i+=1
      cur+=1
    num = 1
    if i==n:
      l.append(cur)
print(sum(l))

Submission status: Wrong Answer

Solution code:
from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)


import os
import sys
from sys import *
from io import BytesIO, IOBase

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

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()



sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
z = lambda: sys.stdin.readline().rstrip("\r\n")



def op():
    return list(map(int,z().split()))
def o():
    return int(z())
def r(x):
    if type(x)==int:
        return range(x)
    else:return range(len(x))
def kl(con,x=0):
    if x==0:print('Yes') if con else print('No')
    elif x==1:print('yes') if con else print('no')
    elif x==2:print('YES') if con else print('NO')
MOD = 1000000007
MAX=float('inf')
MIN=-float('inf')
x=z()
c=0
f=0
l1,l2=[],[]
for i in x:
    if i=='<':
        c+=1
        l1.append(c)
    else:
        c=0
        l1.append(c)
for i in x[::-1]:
    if i=='>':
        c+=1
        l2.append(c)
    else:
        c=0
        l2.append(c)
l2=l2[::-1]
ans=[]
for i in r(len(x)-1):
      ans.append(max(l1[i],l2[i+1]))
ans.insert(0,l2[0])
ans.append(l1[-1])
print(ans)
print(sum(ans))

Submission status: Wrong Answer

Solution code:
s = input()
s = s.replace('><','> <')
k = list(s.split())
c = 0
for v in k:
  r = len(v)
  g = 0
  if '<>' in v:
    f = v.find('<>')
    mi = min(f+1,r-f-1)
    ma = max(f+1,r-f-1)
    c += (ma*(ma+1)//2) + (mi*(mi-1)//2)
  elif '<' in v:
    c += r
  else:
    c += r
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    S = gete()

    p = []
    nl, ng = 0, 0  # <, >

    for i, c in enumerate(S):
        if c == "<":
            nl += 1
        else:
            ng += 1

        if c == "<" and i < len(S) - 1 and S[i + 1] == ">":
            p.append((ng, nl))
            nl, ng = 0, 0

    p.append((ng, nl))

    ans = 0
    for i, q in enumerate(p):

        if i == 0 or p[i - 1][1] < q[0]:
            ans += q[0] * (q[0] + 1) // 2
        else:
            ans += q[0] * (q[0] - 1) // 2

        if i == len(p) - 1 or q[1] >= p[i + 1][0]:
            ans += q[1] * (q[1] + 1) // 2
        else:
            ans += q[1] * (q[1] - 1) // 2

    print(p)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    S = gete()

    p = []
    nl, ng = 0, 0  # <, >

    for i, c in enumerate(S):
        if c == "<":
            nl += 1
        else:
            ng += 1

        if c == "<" and i < len(S) - 1 and S[i + 1] == ">":
            p.append((ng, nl))
            nl, ng = 0, 0

    p.append((ng, nl))

    ans = 0
    for i, q in enumerate(p):

        if i == 0 or p[i - 1][1] <= q[0]:
            ans += q[0] * (q[0] + 1) // 2
        else:
            ans += q[0] * (q[0] - 1) // 2

        if i == len(p) - 1 or q[1] >= p[i + 1][0]:
            ans += q[1] * (q[1] + 1) // 2
        else:
            ans += q[1] * (q[1] - 1) // 2

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# A - ><
S = input()
N = len(S)+1
INF = 1000000
ans = [0]*N
tmp = -INF
for i in range(N-1):
    if S[i]=='<':
        tmp += 1
    else:
        tmp = 0
    ans[i+1] = tmp
tmp = -INF
for i in range(N-2,-1,-1):
    if S[i]=='>':
        tmp += 1
    else:
        tmp = 0
    ans[i] = max(ans[i],tmp)
print(sum(ans))

Submission status: Wrong Answer

Solution code:
import sys
S = list(">")
lis = [0] * (len(S)+1)

if len(S) == 1:
    print(1)
    sys.exit()


#最初は < を処理する
for i in range(len(S)):
    if S[i] == "<":
        lis[i+1] = lis[i] + 1




for j in range(len(S)-1,-1,-1):
    if S[j] == ">":
        lis[j] = max(lis[j],lis[j+1] + 1)



print(sum(lis))

Submission status: Wrong Answer

Solution code:
import sys
S = list(">")
lis = [0] * (len(S)+1)

if len(S) == 1:
    print(1)
    sys.exit()


#最初は < を処理する
for i in range(len(S)):
    if S[i] == "<":
        lis[i+1] = lis[i] + 1




for j in range(len(S)-2,-1,-1):
    if S[j] == ">":
        lis[j] = max(lis[j],lis[j+1] + 1)



print(sum(lis))

Submission status: Wrong Answer

Solution code:
import sys
S = list(input())
lis = [0] * (len(S)+1)

if len(S) == 1:
    print(1)
    sys.exit()


#最初は < を処理する
for i in range(len(S)):
    if S[i] == "<":
        lis[i+1] = lis[i] + 1




for j in range(len(S)-1,0,-1):
    if S[j] == ">":
        lis[j] = max(lis[j],lis[j+1] + 1)



print(sum(lis))

Submission status: Wrong Answer

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

#最初は < を処理する
for i in range(len(S)):
    if S[i] == "<":
        lis[i+1] = lis[i] + 1




for j in range(len(S)-1,0,-1):
    if S[j] == ">":
        lis[j] = max(lis[j],lis[j+1] + 1)



print(sum(lis))

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
a=[0]*(len(s)+1)
for i in range(1,len(s)+1):
    a[i]=a[i-1]+i
R=L=0
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        if s[i]==">":
            R+=1
        else:L+=1
    else:
        if s[i]=="<":
            ans+=a[max(R,L)]+a[max(0,min(R,L)-1)]
            R=0
            L=1
        else:R+=1    
print(ans+a[max(R,L)]+a[max(0,min(R,L)-1)])

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
a=[0]*(len(s)+1)
for i in range(1,len(s)+1):
    a[i]=a[i-1]+i
R=L=0
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        if s[i]==">":
            R+=1
        else:L+=1
    else:
        if s[i]=="<":
            ans+=a[max(R,L)]+a[max(0,min(R,L)-1)]
            R=0
            L=1
        else:R+=1    
    print(ans,R,L)
print(ans+a[max(R,L)]+a[max(0,min(R,L)-1)])

Submission status: Wrong Answer

Solution code:
S = list("<>>><<><<<<<>>><")
lis = [0] * (len(S)+1)

#最初は < を処理する
for i in range(len(S)):
    if S[i] == "<":
        lis[i+1] = lis[i] + 1

num = len(lis)
for i in reversed(S):
    num = num-1
    if i == "<":
        lis[num] = lis[num] + 1

Submission status: Wrong Answer

Solution code:
S = input()
prev = ">"
terrain = []
curr = 0
for c in S:
    if c == prev:
        curr += 1
    else:
        prev = c
        terrain.append(curr)
        curr = 1
terrain += [curr]
ans = (terrain[0] * (terrain[0] + 1)) // 2
for t_down, t_up in zip(terrain[2::2], terrain[1::2]):
    if t_down < t_up:
        t_down, t_up = t_up, t_down
    t_up -= 1
    ans += (t_down * (t_down + 1)) // 2
    ans += (t_up * (t_up + 1)) // 2
if len(terrain) % 2 == 0:
    ans += terrain[-1]
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
m = 0
num = 0
for c in S:
  if c == '<':
    num += 1
  elif c == '>':
    num -= 1
  m = min(num, m)
if m < 0:
  num += -m
else:
  num = 0

ans = 0
ans += num
for c in S:
  if c == '<':
    num += 1
  elif c == '>':
    num -= 1
  ans += num
print(ans)

Submission status: Wrong Answer

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