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()
l = 0
r = 0
a = []
cnt = 0
for i in range(len(S)-1):
  if S[i] == "<":
    l += 1
  else:
    r += 1
  if S[i] != S[i+1]:
    cnt += 1
    if cnt == 2:
      a.append([l, r])
      l, r, cnt = 0, 0, 0
  if i == len(S)-2 and cnt < 2:
    if S[i+1] == ">":
      r += 1
    else:
      l += 1
    a.append([l, r])
ans = 0
for i in a:
  mx = max(i[0], i[1])
  mn = min(i[0], i[1])
  ans += mx*(mx+1)/2 + mn*(mn+1)/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
S = input()
l = 0
r = 0
a = []
cnt = 0
for i in range(len(S)-1):
  if S[i] == "<":
    l += 1
  else:
    r += 1
  if S[i] != S[i+1]:
    cnt += 1
    if cnt == 2:
      a.append([l, r])
      l, r, cnt = 0, 0, 0
  if i == len(S)-2:
    if S[i+1] == ">":
      r += 1
    else:
      l += 1
    a.append([l, r])
ans = 0
for i in a:
  mx = max(i[0], i[1])
  mn = min(i[0], i[1])
  ans += mx*(mx+1)/2 + mn*(mn-1)/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
L = input()
L = list(L.split('><'))
if len(L) == 1:
    ans = len(L)*(len(L)+1)/2
else:
    ans = 0
    for i in range(len(L)):
        if i == 0:
            a = [L[i].count('<'),L[i].count('>')+1]
        elif i == len(L)-1:
            a = [L[i].count('<')+1,L[i].count('>')]
        else:
            a = [L[i].count('<')+1,L[i].count('>')+1]
        a_max = max(a)
        a_min = min(a)

        ans += a_max*(a_max+1)/2
        ans += a_min*(a_min-1)/2

print(int(ans))

Submission status: Wrong Answer

Solution code:
L = input()
L = list(L.split('><'))

ans = 0
for i in range(len(L)):
    if i == 0:
        a = [L[i].count('<'),L[i].count('>')+1]
    elif i == len(L)-1:
        a = [L[i].count('<')+1,L[i].count('>')]
    else:
        a = [L[i].count('<')+1,L[i].count('>')+1]
    a_max = max(a)
    a_min = min(a)

    ans += a_max*(a_max+1)/2
    ans += a_min*(a_min-1)/2

print(int(ans))

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)
if(l%2 == 0):n = int(l/2)
else:n = int(l/2)+1
print(int(n*(n+1)/2))

Submission status: Wrong Answer

Solution code:
L = list(input())
N = [-1 for i in range(len(L)+1)]

def sounyu(L,N):    
    for i in range(len(N)-1):
        if L[i] == '<':
            N[i] = max(N[i],0)
            while(L[i] == '<'):
                N[i+1] = max(N[i+1],N[i]+1)
                i += 1
                if i == len(L):
                    break

sounyu(L,N)
print(N)
L.reverse()
for l in range(len(L)):
    if L[l] == '>':
        L[l] = '<'
    else:
        L[l] = '>'
N.reverse()
sounyu(L,N)
print(N)

print(sum(N))

Submission status: Wrong Answer

Solution code:
S = input()
number = 0
MAX = 0
MIN = 0
ans = 0
for s in S:
    if s == '<':
        number += 1
        MAX = max(MAX,number)
    else:
        number -= 1
        MIN = min(MIN,number)
MAX -= MIN
for i in range(1,MAX+1):
    ans += i
print(ans)

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]+=1
  else:
    A[i+1]-=1
minimum=-1*min(A)
print(minimum*(len(S)+1)+sum(A))

Submission status: Wrong Answer

Solution code:
0

Submission status: Wrong Answer

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

for i in range(N):
    if S[i] == '<':
        l[i + 1] = max(l[i + 1], l[i] + 1)
for i in range(0, N)[::-1]:
    if S[i] == '>':
        l[i] = max(l[i], l[i + 1] + 1)

# print(sum(l))
print(l)

Submission status: Wrong Answer

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

for i in range(N):
    if S[i] == '<':
        l[i + 1] = max(l[i + 1], l[i] + 1)
for i in range(1, N)[::-1]:
    if S[i] == '>':
        l[i] = max(l[i], l[i + 1] + 1)

print(sum(l))
# print(l)

Submission status: Wrong Answer

Solution code:
#AGC-040
#端っこは先に処理する形にする。
S = input()
A = [0] * (len(S) + 1)

def check_left(n, S):
    count = 0
    for i in reversed(range(0, n)):
        if S[i] == "<":
            count += 1
        else:
            break
    return count

def check_right(n, S):
    count = 0
    for i in range(n, len(S)):
        if S[i] == ">":
            count += 1
        else:
            break
    return count

#追加
if S[0] == "<":
    A[0] = 0
else:
    A[0] = max(check_left(0, S), check_right(0, S))
    
for i in range(1, len(S)):
    if A[i-1] != 0:
        if S[i-1] == "<":
            A[i] = A[i-1] + 1
        else:
            if S[i] == "<":
                A[i] = 0
            else:
                A[i] = max(check_left(i, S), check_right(i, S))
    else:
        A[i] = max(check_left(i, S), check_right(i, S))

#追加
if S[-1] == ">":
    A[-1] = 0
else:
    A[-1] = max(check_left(len(S), S), check_right(len(S), S))

print(sum(A))

Submission status: Wrong Answer

Solution code:
#AGC-040
S = input()
A = [0] * (len(S) + 1)

def check_left(n, S):
    count = 0
    for i in reversed(range(0, n)):
        if S[i] == "<":
            count += 1
        else:
            break
    return count

def check_right(n, S):
    count = 0
    for i in range(n, len(S)):
        if S[i] == ">":
            count += 1
        else:
            break
    return count

for i in range(len(S)+1):
    if i > 0 and i < (len(S)-1) and A[i-1] != 0:
        if S[i-1] == "<":
            A[i] = A[i-1] + 1
        elif S[i-1] == ">" and S[i] == "<":
            A[i] = 0
        else:
            A[i] = max(check_left(i, S), check_right(i, S))
    else:
        A[i] = max(check_left(i, S), check_right(i, S))

if S[-1] == ">":
    A[-1] = 0

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

Submission status: Wrong Answer

Solution code:
#AGC-040
S = input()
A = [0] * (len(S) + 1)

def check_left(n, S):
    count = 0
    for i in reversed(range(0, n)):
        if S[i] == "<":
            count += 1
        else:
            break
    return count

def check_right(n, S):
    count = 0
    for i in range(n, len(S)):
        if S[i] == ">":
            count += 1
        else:
            break
    return count

for i in range(len(S)+1):
    if i > 0 and A[i-1] != 0:
        if S[i-1] == ">":
            if i < (len(S) - 1) and S[i+1] == "<":
                A[i] = 0
            else:
                A[i] = max(check_left(i, S), check_right(i, S))
        else:
            A[i] = A[i-1] + 1
    else:
        A[i] = max(check_left(i, S), check_right(i, S))

if S[-1] == ">":
    A[-1] = 0
    
print(sum(A))

Submission status: Wrong Answer

Solution code:
#AGC-040
S = input()
A = [0] * (len(S) + 1)

def check_left(n, S):
    count = 0
    for i in reversed(range(0, n)):
        if S[i] == "<":
            count += 1
        else:
            break
    return count

def check_right(n, S):
    count = 0
    for i in range(n, len(S)):
        if S[i] == ">":
            count += 1
        else:
            break
    return count

for i in range(len(S)+1):
    if i > 0 and A[i-1] != 0:
        if S[i-1] == ">":
            if i < (len(S) - 1) and S[i+1] == "<":
                A[i] = 0
            else:
                A[i] = A[i-1] - 1
        else:
            A[i] = A[i-1] + 1
    else:
        A[i] = max(check_left(i, S), check_right(i, S))

if S[-1] == ">":
    A[-1] = 0
    
print(sum(A))

Submission status: Wrong Answer

Solution code:
#AGC-040
S = input()
A = [0] * (len(S) + 1)

def check_left(n, S):
    count = 0
    for i in reversed(range(0, n)):
        if S[i] == "<":
            count += 1
        else:
            break
    return count

def check_right(n, S):
    count = 0
    for i in range(n, len(S)):
        if S[i] == ">":
            count += 1
        else:
            break
    return count

for i in range(len(S)+1):
    if i > 0 and A[i-1] != 0:
        if S[i-1] == ">":
            if i < (len(S) - 1) and S[i+1] == "<":
                A[i] = 0
            else:
                A[i] = A[i-1] - 1
        else:
            A[i] = A[i-1] + 1
    else:
        A[i] = max(check_left(i, S), check_right(i, S))
    
print(sum(A))

Submission status: Wrong Answer

Solution code:
w1 = input()
length = len(w1)
num_list = [-1]*(length+1)
c1 = 0
c2 = 0
for i in range(length):
    if i==0 and w1[i] == "<":
        num_list[0] = 0
    if i==(length-1) and w1[i] == ">":
        num_list[length] = 0
    if not i==length-1:
        if w1[i] == ">" and w1[i+1] =="<":
            num_list[i+1] = 0

    if(w1[i] == "<"):
        num_list[i+1] = num_list[i] + 1

for i in range(length-1,-1,-1):
    if (w1[i] == ">"):
        if(num_list[i] < num_list[i+1] + 1):
            num_list[i] = num_list[i+1] + 1

allsum = 0
print(num_list)
print(sum(num_list))

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

#0<>>>0<<>0<<<<<>>>0<

Submission status: Wrong Answer

Solution code:
import re
from collections import Counter
s = input()
res = re.findall(r"<+>*", s)

def calc(string):
    ct = Counter(string)
    cnt_d = ct[">"]
    cnt_s = ct["<"]
    if cnt_s > cnt_d:
        return (cnt_s * (cnt_s + 1) + (cnt_d - 1) * cnt_d) // 2
    elif cnt_s == cnt_d:
        return cnt_s * cnt_s
    else:
        return ((cnt_d + 1) * cnt_d + (cnt_s - 1) + cnt_s) // 2
score = 0
for r in res:
    score += calc(r)
print(score)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

for j in range(n-1):
    if s[-j-1] == ">":
        v[-j-2] = v[-j-1] + 1

print(sum(v))

Submission status: Wrong Answer

Solution code:
S = input()
ans = 0

big = [0]*(len(S)+1)
for i in range(len(S)):
  if S[i] == "<":
    big[i+1] = big[i] +1
  else:
    big[i+1] = 0
  
small = [0]*(len(S)+1)
for i in range(len(S)-1, 0, -1):
  if S[i] == ">":
    small[i] = small[i+1] + 1
  else:
    small[i] = 0
    
for b, s in zip(big, small):
  ans += max(b, s)

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

idx_mountain = -1
idx_vally = -1
sum = 0

for i in range(len(s)-1):
  if s[i]+s[i+1] == "><":
    sum += 0.5 * (idx_mountain - idx_vally) * (idx_mountain - idx_vally + 1)
    sum += 0.5 * (i - idx_mountain) * (i - idx_mountain + 1)
    sum -= min(idx_mountain - idx_vally, i - idx_mountain)
    idx_vally = i
  elif s[i]+s[i+1] == "<>":
    idx_mountain = i
    
if idx_mountain < idx_vally:
  sum += 0.5 * (len(s)-1 - idx_vally) * (len(s)-1 - idx_vally + 1)
elif idx_mountain > idx_vally:
  sum += 0.5 * (idx_mountain - idx_vally) * (idx_mountain - idx_vally + 1)
  sum += 0.5 * (len(s)-1 - idx_mountain) * (len(s)-1 - idx_mountain + 1)
  sum -= min(len(s)-1 - idx_mountain, idx_mountain - idx_vally)
else:
  sum = 1
print(int(sum))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(8)

Submission status: Wrong Answer

Solution code:
s = input()

res = 0
i = 0
while (i < len(s)):
    a, b = 0, 0
    while (i < len(s) and s[i] == '<'):
        i += 1
        a += 1
    while (i < len(s) and s[i] == '>'):
        i += 1
        b += 1
    c = min(a, b)
    d = max(a, b)
    print(c, d)
    res += (c * (c - 1)) // 2
    res += (d * (d + 1)) // 2

print(res)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
list =[0 for _ in range(n+1)]

for x in range(n-1):
    for y in range(n-1-x):
        if '<' == s[y] and list[y] > list[y+1]:
            list[y] = list[y+1]
            list[y+1] = list[y]
        elif '<' == s[y] and list[y] < list[y+1]:
            list[y] = list[y]
            list[y+1] = list[y+1]
        elif '>' == s[y] and list[y] > list[y+1]:
            list[y] = list[y]
            list[y+1] = list[y+1]
        elif '>' == s[y] and list[y] < list[y+1]:
            list[y] = list[y+1]
            list[y] = list[y]

print(sum(list))

Submission status: Wrong Answer

Solution code:
s = input()

total = 0
tmp_current = 0
tmp_high = 0
count_from_high = 1
flag_current = True # '<':True, '>':False
for c in s:
    if c == '<':
        if not flag_current:
            count_from_high = 0
        total += tmp_current+1
        tmp_current += 1
        flag_current = True
    else:
        if flag_current:
            tmp_high = tmp_current
            flag_current = False
        else:
            if tmp_high > count_from_high:
                total += count_from_high
            else:
                total += count_from_high + 1
        tmp_current = 0
        count_from_high += 1
print(total)

Submission status: Wrong Answer

Solution code:
s = input()

total = 0
tmp_current = 0
tmp_high = 0
count_from_high = 0
flag_current = True # '<':True, '>':False
for c in s:
    if c == '<':
        if not flag_current:
            count_from_high = 0
        total += tmp_current+1
        tmp_current += 1
        flag_current = True
    else:
        if flag_current:
            tmp_high = tmp_current
            flag_current = False
        else:
            if tmp_high > count_from_high:
                total += count_from_high
            else:
                total += count_from_high + 1
        tmp_current = 0
        count_from_high += 1
print(total)

Submission status: Wrong Answer

Solution code:
S = input()
list = [100 for i in range(len(S))]
list.append(100)
cnt = 0
min = 0
if S[0] == "<":
	cnt = 1
	list[0] = 0
if S[-1] == ">":
	list[len(S)] = 0
for i in range(len(S)-1):
	if S[i] == ">" and S[i+1] == "<":
		list[i+1] = 0
		cnt = 1
for i in range(len(S)):
	if S[i] == "<":
		if list[i] == 0:
			cnt = 1
		list[i+1] = cnt
		cnt += 1
#print("lsit",list)

for i in range(len(S)-1):
	if S[len(S) - i - 1] == ">" and S[len(S) - i - 2] == "<":
		list[len(S) - i-1] = max(list[len(S) - i-1],list[len(S) - i]+1)
	elif S[len(S) - i - 1] == ">":
		list[len(S) - i-1] = list[len(S) - i]+1		
#print(list)
print(sum(list))

Submission status: Wrong Answer

Solution code:
S = input()
list = [100 for i in range(len(S))]
list.append(100)
cnt = 0
min = 0
if S[0] == "<":
	cnt = 1
	list[0] = 0
if S[-1] == ">":
	list[len(S)] = 0
for i in range(len(S)-1):
	if S[i] == ">" and S[i+1] == "<":
		list[i+1] = 0
		cnt = 1
for i in range(len(S)):
	if S[i] == "<":
		list[i+1] = cnt
		cnt += 1
#print("lsit",list)

for i in range(len(S)-1):
	if S[len(S) - i - 1] == ">" and S[len(S) - i - 2] == "<":
		list[len(S) - i-1] = max(list[len(S) - i-1],list[len(S) - i]+1)
	elif S[len(S) - i - 1] == ">":
		list[len(S) - i-1] = list[len(S) - i]+1		
#print(list)
print(sum(list))

Submission status: Wrong Answer

Solution code:
s = input()

prev = s[0]
curr = s[0]
count = 0
total = 0

for n in range(len(s)):
    curr=s[n]
    if prev == curr:
        count += count + 1
    else:
        total += count
        count = 0
    prev = curr

total += count

print(total)

Submission status: Wrong Answer

Solution code:
def main():
  s = input().rstrip('\n')
  n = len(s)
  dp = [0] * (1 + n)
  for i,c in enumerate(s):
    if c == '<':
      dp[i+1] = dp[i] + 1
  for i in range(n-1, -1, -1):
    if s[i] == '>':
      dp[i] = dp[i+1] + 1
  return sum(dp)

print(main())

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] = 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()
N=len(S)+1

a=[0]
temp=0
f=0
mx_idx=0

for i in range(1,N):
    if S[i-1]=="<":
        if f>=0: 
            a.append(a[i-1]+1)
            temp+=1
            f=1
        else: 
            if temp>0:
                for j in range(mx_idx+1,i):
                    a[j]-=temp
            elif temp<0:
                for j in range(mx_idx,i):
                    a[j]-=temp
            a.append(1)
            temp=1
            f=1
    else:
        if f<=0:
            a.append(a[i-1]-1)
            temp-=1
        else: 
            a.append(a[i-1]-1)
            temp-=1
            mx_idx=i-1
            f=-1

if temp<0:
    for j in range(mx_idx, N):
        a[j] -= temp
print(sum(a))

Submission status: Wrong Answer

Solution code:

str = input()
num = 0
sum = 0
for s in str:
  if s == ">":
    num += 1
    sum += num
    
print(sum)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
ans = [0]*(n+1)
for i in range(n):
    if S[i]=='<':
        ans[i]=ans[i-1]+1
for i in range(n-1,-1,-1):
    if S[i]==">":
        ans[i]=ans[i+1]+1
res = 0
for i in range(n+1):
    res+=ans[i]
print(res)

Submission status: Wrong Answer

Solution code:
import math
m=input()
k=1
f=0
for i in range(len(m)-1):
  if m[i]==m[i+1]:
    k+=1
  else:
    f+=math.factorial(k)
    k=1
f+=math.factorial(k)
print(f)

Submission status: Wrong Answer

Solution code:
s = input()
prev = 0
now = 0
t = []
for i in range(len(s)):
    if i == 0:
        prev = s[i]
        now = 1
    elif s[i] == "<":
        if prev == "<":
            now += 1
        else:
            t.append(now)
            now = 1
        prev = "<"
    else:
        if prev == ">":
            now += 1
        else:
            t.append(now)
            now = 1
        prev = ">"
t.append(now)
ans = 0
if s[0] == "<":
    if len(t) % 2 == 1:
        ans += 1
    for i in range(1, len(t)):
        if i % 2 == 1:
            if i < len(t) - 1:
                k = max(t[i], t[i + 1])
            else:
                k = t[i]
            ans += k * (k + 1) // 2
else:
    for i in range(0, len(t)):
        if i % 2 == 0:
            if i < len(t) - 1:
                k = max(t[i], t[i + 1])
            else:
                k = t[i]
            ans += k * (k + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

s = str(input())
s += '0'
c = s[0]
ran = []
num = 1
for i in range(1, len(s)):
    if c == s[i]:
        num += 1
    elif s[i] == '0':
        ran.append(num)
    else:
        ran.append(num)
        c = s[i]
        num = 1
result = ran[0]
if s[0] == '<':
    result = ((ran[0]-1)*ran[0])//2
    h = True
else:
    result = ((1+ran[0])*ran[0])//2
    h = False

if len(c) == 1:
    result = ((1+ran[0])*ran[0])//2
for i in range(1, len(ran)):
    if h:
        if ran[i-1] < ran[i]:
            result += ((1+ran[i])*ran[i])//2
        else:
            result += ((ran[i]-1)*ran[i])//2 + ran[i-1]
        h = False
    else:
        result += ((ran[i]-1)*ran[i])//2
        h = True
        if i == len(ran)-1:
            result += ran[i]
print(int(result))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

s = str(input())
s += '0'
c = s[0]
ran = []
num = 1
for i in range(1, len(s)):
    if c == s[i]:
        num += 1
    elif s[i] == '0':
        ran.append(num)
    else:
        ran.append(num)
        c = s[i]
        num = 1
result = ran[0]
if s[0] == '<':
    result = ((ran[0]-1)*ran[0])//2
    h = True
else:
    result = ((1+ran[0])*ran[0])//2
    h = False
if len(s) == 1:
    result = 1
for i in range(1, len(ran)):
    if h:
        if ran[i-1] < ran[i]:
            result += ((1+ran[i])*ran[i])//2
        else:
            result += ((ran[i]-1)*ran[i])//2 + ran[i-1]
        h = False
    else:
        result += ((ran[i]-1)*ran[i])//2
        h = True
        if i == len(ran)-1:
            result += ran[i]
print(int(result))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

s = str(input())
s += '0'
c = s[0]
ran = []
num = 1
for i in range(1, len(s)):
    if c == s[i]:
        num += 1
    elif s[i] == '0':
        ran.append(num)
    else:
        ran.append(num)
        c = s[i]
        num = 1
result = ran[0]
if s[0] == '<':
    result = ((ran[0]-1)*ran[0])//2
    h = True
else:
    result = ((1+ran[0])*ran[0])//2
    h = False
for i in range(1, len(ran)):
    if h:
        if ran[i-1] < ran[i]:
            result += ((1+ran[i])*ran[i])//2
        else:
            result += ((ran[i]-1)*ran[i])//2 + ran[i-1]
        h = False
    else:
        result += ((ran[i]-1)*ran[i])//2
        h = True
        if i == len(ran)-1:
            result += ran[i]
print(int(result))

Submission status: Wrong Answer

Solution code:
s = str(input())
s += '0'
c = s[0]
ran = []
num = 1
for i in range(1, len(s)):
    if c == s[i]:
        num += 1
    elif s[i] == '0':
        ran.append(num)
    else:
        ran.append(num)
        c = s[i]
        num = 1
result = ran[0]
if s[0] == '<':
    result = ((ran[0]-1)*ran[0])//2
    h = True
else:
    result = ((1+ran[0])*ran[0])//2
    h = False
for i in range(1, len(ran)):
    if h:
        if ran[i-1] < ran[i]:
            result += ((1+ran[i])*ran[i])//2
        else:
            result += ((ran[i]-1)*ran[i])//2 + ran[i-1]
        h = False
    else:
        result += ((ran[i]-1)*ran[i])//2
        h = True
        if i == len(ran)-1:
            result += ran[i]
print(int(result))

Submission status: Wrong Answer

Solution code:
s = str(input())
s += '0'
c = s[0]
ran = []
num = 1
for i in range(1, len(s)):
    if c == s[i]:
        num += 1
    elif s[i] == '0':
        ran.append(num)
    else:
        ran.append(num)
        c = s[i]
        num = 1
result = ran[0]
if s[0] == '<':
    result = ((ran[0]-1)*ran[0])//2
    h = True
else:
    result = ((1+ran[0])*ran[0])//2
    h = False
for i in range(1, len(ran)):
    if h:
        if ran[i-1] <= ran[i]:
            result += ((1+ran[i])*ran[i])//2
        else:
            result += ((ran[i]-1)*ran[i])//2 + ran[i-1]
        h = False
    else:
        result += ((ran[i]-1)*ran[i])//2
        h = True
        if i == len(ran)-1:
            result += ran[i]
print(result)

Submission status: Wrong Answer

Solution code:
#AGC040
import sys
s = sys.stdin.readline().rstrip()
n = len(s)
L = [0 for _ in range(n+1)]

for i in range(n):
    if s[i] == '<':
        L[i+1] = L[i] +1

#print(L)

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

#print(L)

print(sum(L))

Submission status: Wrong Answer

Solution code:
s = input()
s_list=list(s)
num_min = 2
num_max = 500000
num_list =[0,]
countl=1
for x in s_list:
    if x == "<":
        num_list.append(num_list[-1]+1)
        countl =1
        continue
    if x == ">":
        num_list.append(num_list[-1]-1)
        countl +=1
    if num_list[-1]<0:
        for l in range(countl,0,-1):
            l =l*(-1)
            num_list[l] +=1
            
sum_num = sum(num_list)

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
for j in range(n-2,0,-1):
    if s[j]==">":
        a[j]=max(a[j+1]+1,a[j])
print(sum(a))

Submission status: Wrong Answer

Solution code:
s = input()
arr = [0]
for i in range(len(s)):
  if s[i] == '<':
    arr.append(arr[i]+1)
  else:
    arr.append(0)
#print(len(arr))
for i in reversed(range(len(s))):
  if s[i] == '>':
    arr[i] = max(arr[i],arr[i+1]+1)
print(sum(arr))
print(arr)

Submission status: Wrong Answer

Solution code:
str = input()
char_list=[]
ans_list=[]
ans_list.insert(0,0)
print(ans_list)

char_list = list(str)
n=len(char_list)

Submission status: Wrong Answer

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


calculate(input())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
 
def calculate(input):
  il = list(input)
  ilSize = len(il)
  o = [0] * (ilSize + 1)
  for (i, symbol) in enumerate(il):
    ci = i + 1
    if symbol == '<':
      o[ci] = o[ci - 1] + 1
      pass
    for pi in range(i, -1, -1):
      if il[pi] != '>' or o[pi] > o[pi + 1]:
        break
      o[pi] = o[pi + 1] + 1
  return sum(o)
 
for input in sys.stdin:
  calculate(input)

Submission status: Wrong Answer

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

#  < > < だと n=2
#  一旦0を全部に入れる
a = [0]*(n+2)

#  左から右に　< だと　a[i+1]はa[i]+1
for i in range(n):
    if s[i] == '<':
        a[i+1] = a[i]+1

#  右から左に > だた a[i]はa[i+1]+1
for i in range(n-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 = list(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(n-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()
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 reversed(range(len(S))):
    if S[i] == '>':
        a[i] = max(a[i], a[i+1]-1)
ans = sum(a)

print(ans)

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)
    if S[i] == '>':
        a[i+1] = min(a[i+1], a[i]-1)
ans = sum(a)

print(ans)

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)
    if S[i] == '<':
        a[i+1] = min(a[i+1], a[i]-1)
ans = sum(a)

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
baf = S[0]
anscount = 0
count = 0
count2 = 0
count3 = 0
count4 = 0
farstflag = 1
countflag = 0
countflag2 = 0
def plus(N):
    return N * (N - 1) // 2
while(count < len(S)):
    #print("count", count, "Scount", S[count], "farstflag", farstflag, "countflag", countflag, "cfalg2", countflag2, "count3", count3, "count4", count4, "ans", anscount)
    if farstflag == 1 and S[0] == "<":
        farstflag = 0
    if farstflag == 1 and S[0] == ">":
        farstflag = 0
        countflag = 1
    if countflag == 1:
        if baf != S[count]:
            #print(count2)
            anscount += plus(count2 + 1)
            countflag = 0
        count2 += 1
    if farstflag == 0 and countflag == 0 and countflag2 == 0:
        if S[count] == "<":
            count3 += 1
        else:
            countflag2 = 1
            count4 += 1
            count+= 1
            continue
    if farstflag == 0 and countflag == 0 and countflag2 == 1:
        if S[count] == ">":
            count4 += 1
        else:
            anscount += plus(max(count3, count4) + 1)
            anscount += plus(min(count3, count4))
            countflag2 = 0
            count4 = 0
            count3 = 0
            count3 += 1

    baf = S[count]
    count += 1
anscount += plus(max(count3, count4) + 1)
anscount += plus(min(count3, count4))
#print("count", count, "farstflag", farstflag, "countflag", countflag, "cfalg2", countflag2, "count3", count3, "count4", count4, "ans", anscount)

print(anscount)

Submission status: Wrong Answer

Solution code:
S = input()
baf = S[0]
anscount = 0
count = 0
count2 = 0
count3 = 0
count4 = 0
farstflag = 1
countflag = 0
countflag2 = 0
def plus(N):
    return N * (N - 1) // 2
while(count < len(S)):
    #print("count", count, "Scount", S[count], "farstflag", farstflag, "countflag", countflag, "cfalg2", countflag2, "count3", count3, "count4", count4, "ans", anscount)
    if farstflag == 1 and S[0] == "<":
        farstflag = 0
    if farstflag == 1 and S[0] == ">":
        farstflag = 0
        countflag = 1
    if countflag == 1:
        count2 += 1
        if baf != S[count]:
            print(count2)
            anscount += plus(count2 + 1)
            countflag = 0
    if farstflag == 0 and countflag == 0 and countflag2 == 0:
        if S[count] == "<":
            count3 += 1
        else:
            countflag2 = 1
            count4 += 1
            count+= 1
            continue
    if farstflag == 0 and countflag == 0 and countflag2 == 1:
        if S[count] == ">":
            count4 += 1
        else:
            anscount += plus(max(count3, count4) + 1)
            anscount += plus(min(count3, count4))
            countflag2 = 0
            count4 = 0
            count3 = 0
            count3 += 1

    baf = S[count]
    count += 1
anscount += plus(max(count3, count4) + 1)
anscount += plus(min(count3, count4))
#print("count", count, "farstflag", farstflag, "countflag", countflag, "cfalg2", countflag2, "count3", count3, "count4", count4, "ans", anscount)

print(anscount)

Submission status: Wrong Answer

Solution code:
s = input()

numlist = [0]*(len(s)+1)
while True:
    flag = 0
    for i in range(len(s)):
        if s[i]=='<':
            if numlist[i]>=numlist[i+1]:
                numlist[i+1] = numlist[i]+1
                flag = 1 
                print(numlist)
        elif s[i]=='>':
            if numlist[i]<=numlist[i+1]:
                numlist[i] += 1
                print(numlist)
                flag = 1
    if flag == 0:
        break

sum_li = sum(numlist)
print(sum_li)

Submission status: Wrong Answer

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


def main():
    s = list(input())
    n = len(s) + 1
    ans = [0 for _ in range(n)]

    # See:
    # https://www.youtube.com/watch?v=qIzuNgDV6O8
    # KeyInsight:
    # 不等号を一つずつ扱い，全探索で処理
    # <: a[i + 1] = max(a[i + 1], a[i] + 1)
    # >: a[i - 1] = max(a[i - 1], a[i] + 1)

    # 考察できた部分
    # 0で初期化
    # 愚直にサンプルからシミュレーション

    # 考察できなかった部分
    # 各項の値をどうプログラムで求めるか

    # ギャップ
    # 符号をまとめて処理しようとした
    # 途中で，符号の組み合わせによって，カウントを調整必要があることに気がついたが，法則性が分からず
    for i in range(n - 1):
        if s[i] == '<':
            ans[i + 1] = max(ans[i + 1], ans[i] + 1)

    for i in range(n - 2, 0, -1):
        if s[i] == '>':
            ans[i] = max(ans[i], ans[i + 1] + 1)

    print(sum(ans))


if __name__ == '__main__':
    main()

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
for i in range(N-2, -1, -1):
  if S[i] == '>':
    a[i] = max(a[i+1]+1,a[i])
print(a)
print(sum(a))