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

Submission status: Wrong Answer

Solution code:
slist=list(input())
kosu=[]
n=len(slist)
counter=1
for i in range(n-1):
	if slist[i]==slist[i+1]:
		counter+=1
	else:
		kosu.append(counter)
		counter=1
kosu.append(counter)

nagasa=len(kosu)
kotae=0
if nagasa==1:
	kotae=kosu[0]*(kosu[0]+1)/2
else:
	if slist=="<":
		if nagasa%2==0:
			for i in range(0,nagasa,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		else:
			for i in range(0,nagasa-1,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
			kotae+=kosu[-1]*(kosu[-1]+1)/2
	else:
		if nagasa%2!=0:
			for i in range(1,nagasa,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
			kotae+=kosu[0]*(kosu[0]+1)/2
		else:
			for i in range(1,nagasa-1,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
			kotae+=kosu[0]*(kosu[0]+1)/2
			kotae+=kosu[-1]*(kosu[-1]+1)/2
kotae=int(kotae)
print(kotae)

Submission status: Wrong Answer

Solution code:
s_ = input()
s = [one for one in s_]

cnt = 0
tmp_cnt = 0
save_num = 0
tmp_l = []
for i,one in enumerate(s):
    if i == 0:
        tmp = one
        tmp_cnt = 1
    else:
        if one == tmp:
            tmp_cnt += 1
        else:
            tmp_l.append(tmp_cnt)
            tmp_cnt = 1
            tmp = one
tmp_l.append(tmp_cnt)

cnt = 0
for one in tmp_l:
    cnt += 1/2*one*(one-1)
cnt = int(cnt)
for i in range(int(len(tmp_l)//2)):
    cnt += max(tmp_l[2*i],tmp_l[2*i+1])
    
if len(tmp_l) % 2 != 0:
    if tmp == "<":
        cnt += tmp_l[-1]
    else:
        #cnt += 2
        cnt += tmp_l[-1]
else:
    if tmp == "<":
        cnt += tmp_l[-1]
print(cnt)

Submission status: Wrong Answer

Solution code:
S = list(input())
A = [0] * (len(S)+1)
imos = [0] * (len(S))
for i in range(len(S)):
    if S[i] == '>':
        imos[i] = 1
    else:
        imos[i] = -1000000
imos += [0]
for i in range(len(S), 0, -1):
    imos[i-1] = max(0, imos[i-1] + imos[i])

for i in range(len(S)):
    if S[i] == '<':
        A[i+1] = max(imos[i+1], A[i]+1)
    else:
        A[i+1] = max(0, min(A[i]-1, imos[i+1]))
print(sum(A))

Submission status: Wrong Answer

Solution code:
s = input()
t = s.split(">")
t2 = s.split("<")
a = []
b = []
for i in t:
    if i != '':
        a.append(i)

for i in t2:
    if i != '':
        b.append(i)
n = len(a)
n2 = len(b)
if len(b) == 1 and len(a) == 1:
    if s[0] == '>':
        y = len(b[0])
        x = len(a[0])
        sums = 0
        sums += (x * (x + 1)) / 2
        sums += (y * (y + 1)) / 2
        print(int(sums))
        exit()
tmp = min(n, n2)
sums = 0
for i in range(tmp):
    x = len(a[i])
    y = len(b[i])
    if x > y:
        sums += (x * (x + 1)) / 2
        sums += (y * (y - 1)) / 2
    else:
        sums += (x * (x - 1)) / 2
        sums += (y * (y + 1)) / 2
if n > n2:
    x = len(a[n-1])
    sums += (x * (x + 1)) / 2
elif n2 > n:
    x = len(b[n2-1])
    sums += (x * (x + 1)) / 2

print(int(sums))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#0<3>2>1>0<1<2>0<1<2<3<4<5>2>1>0<1
import math
s = input()
bigger=0
smaller=0
count = 0
bigger=1 if s[0]=="<" else 0 
smaller=1 if s[0]==">" else 0 


for i in range(len(s)-1):
    if (s[i]==">" and s[i+1]=="<"):
        count += (max(bigger,smaller))*((max(bigger,smaller))+1)/2
        count += (min(bigger,smaller)-1)*((min(bigger,smaller)-1)+1)/2 if (min(bigger,smaller)-1)!=0 else 0
        bigger = 1
        smaller = 0
    elif (s[i]=="<" and s[i+1]=="<"):
        bigger += 1
    elif (s[i]=="<" and s[i+1]==">"):
        smaller += 1
    elif (s[i]==">" and s[i+1]==">"):
        smaller += 1
count += (max(bigger,smaller))*((max(bigger,smaller))+1)/2
count += (min(bigger,smaller)-1)*(min(bigger,smaller))/2 if smaller!=0 else True

print(int(count))

Submission status: Wrong Answer

Solution code:
s = list(str(input()))
ans = 0
l = []
p = 0
m = 0
n = len(s)
for i in range(n):
  if i == 0:
    if s[i] == "<":
      p += 1
    else:
      m -= 1
  else:
    if s[i] == s[i-1]:
      if s[i] == "<":
        p += 1
        if i == n-1:
          l.append(p)
      else:
        m -= 1
        if i == n-1:
          l.append(m)
    else:
      if s[i] == "<":
        l.append(m)
        m = 0
        p = 1
        if i == n-1:
          l.append(p)
      else:
        l.append(p)
        p = 0
        m = -1
        if i == n-1:
          l.append(m)
      
l.append(0)
for i in range(len(l)-1):
  if l[i] > 0:
    ans += l[i]*(l[i]-1)//2
    ans += max(l[i],-(l[i+1]))
  else:
    ans += (l[i])*(l[i]+1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

def count(s):
    count_bigger = s.count('<')
    count_smaller = s.count('>')
    max_count = max(count_bigger, count_smaller)
    return (count_bigger*(count_bigger-1))/2 + (count_smaller*(count_smaller-1))/2 + max_count

ss = ""
answer = 0
s_before = ""
for i, s in enumerate(S):
    if s_before != "":
        if s_before == ">" and s == "<":
            ss += s_before
            answer += count(ss)
            ss = ""
            if i == len(S)-1:
                ss += s
                answer += count(ss)
        else:
            ss += s_before
            if i == len(S)-1:
                ss += s
                answer += count(ss)
        s_before = s
    else:
        s_before = s
print(int(answer))

Submission status: Wrong Answer

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

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

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

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

#aの最小値
min(a)

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

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

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

Submission status: Wrong Answer

Solution code:

def convert_1d_to_2d(l, cols):
    return [l[i:i + cols] for i in range(0, len(l), cols)]

s = input()

tmp = s[0]
cnt = 1
lst = []
for i in range(1,len(s)):
    if s[i] == tmp:
        cnt += 1
    else:
        lst.append(cnt)
        tmp = s[i]
        cnt = 1
else:
    lst.append(cnt)

num = -1
if len(lst)%2==0:
    l = convert_1d_to_2d(lst, 2)
else:
    if s[0] == '<':
        num = lst[-1] 
        l = convert_1d_to_2d(lst[:-1], 2)
    else:
        num = lst[0]
        l = convert_1d_to_2d(lst[1:], 2)
ans = 0
for i in range(len(l)):
    a = max(l[i][0],l[i][1])
    b = min(l[i][0],l[i][1])
    if a==1 and b==1:
        ans += 1
    elif b == 1 and a != 1:
        ans += (a+1)*a//2
    else:
        ans += a*(a+1)//2 + b*(b-1)//2
if num > 0:
    ans += num
print(ans)

Submission status: Wrong Answer

Solution code:
s_ = input()
s = [one for one in s_]

cnt = 0
tmp_cnt = 0
save_num = 0
tmp_l = []
for i,one in enumerate(s):
    if i == 0:
        tmp = one
        tmp_cnt = 1
    else:
        if one == tmp:
            tmp_cnt += 1
        else:
            tmp_l.append(tmp_cnt)
            tmp_cnt = 1
            tmp = one
tmp_l.append(tmp_cnt)

cnt = 0
for one in tmp_l:
    cnt += 1/2*one*(one-1)
cnt = int(cnt)
for i in range(int(len(tmp_l)//2)):
    cnt += max(tmp_l[2*i],tmp_l[2*i+1])
    
if len(tmp_l) % 2 != 0:
    if tmp == "<":
        cnt += tmp_l[-1]
    else:
        #cnt += 2
        cnt += tmp_l[-1]
print(cnt)

Submission status: Wrong Answer

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

S = input()
a = 0
sum_a = 0
min_a = 0
c = 0
for s in S:
    if s == '<':
        if c > a:
            sum_a += int((1 + c) / 2 * c - a)
            a = 1
            sum_a += 1
            c = 0
        elif c > 0:
            sum_a += int((c) / 2 * (c - 1))
            a = 1
            sum_a += 1
            c = 0
        else:
            a += 1
            sum_a += a
            c = 0
    else:
        c += 1
else:
    if c > a:
        sum_a += int((1 + c) / 2 * c - a)
        a = 1
        c = 0
    elif c > 0:
        sum_a += int((c) / 2 * (c - 1))
        a = 1
        c = 0

print(sum_a)

Submission status: Wrong Answer

Solution code:
s=list(input())
count=0
count1=0
ans=0
for i in range(len(s)):
    if s[i]=='<' and i==len(s)-1:
        count+=1
        ans+=count*(count+1)//2
        #print(ans)
    elif s[i]=='>' and i==len(s)-1:
        count1+=1
        ans+=count1*(count1+1)//2
        #print(ans)
    if count>0 and s[i]=='>':
        if count==1:
            if i==2 or i==len(s)-1:
                ans+=1
                count=0
                count1+=1
                continue
            else:
                count=0
                count1+=1
                continue
        else:
            if i==len(s)-1:
                ans+=(count-1)*count//2
                count=0
                count1+=1
                #print(ans)
                continue
            else:
                ans+=(count+1)*count//2
                count=0
                count1+=1
                #print(ans)
                continue
    elif count1>0 and s[i]=='<':
        if count1==1:
            if i==2 or i==len(s)-1:
                ans+=1
                count1=0
                count+=1
                continue
            else:
                count1=0
                count+=1
                continue
        else:
            if i==len(s)-1:
                ans+=(count1-1)*count1//2
                count1=0
                count+=1
                #print(ans)
                continue
            else:
                ans+=(count1+1)*count1//2
                count1=0
                count+=1
                #print(ans)
                continue
        #------------------------------------------
    if s[i]=='<':
        count+=1
    else:
        count1+=1
print(ans)

Submission status: Wrong Answer

Solution code:
def p(num):

  count = 1
  result = ''
  max_count = 0

  for i in range(len(num)):
    try:
        if num[i] == num[i+1]:
           count = count + 1
        else:
            result = result + str(num[i]) + str(count)
            if max_count < count:
              max_count = count
            count = 1
    except:

          result = result + str(num[i]) + str(count)
  return result, max_count

S = input()
S, _ = p(S)
pre = 0
count =0
for i in range(int(len(S)/2)):

  if S[i*2] == ">":
    n = int(S[i*2+1])
    sum_ = int(n*(n+1)/2)
    count += sum_

    
    count -= min(pre,n)
 
  elif S[i*2] == "<":
    n = int(S[i*2+1])
    sum_ = int(n*(n+1)/2)
    count += sum_
    pre = n


print(count)

Submission status: Wrong Answer

Solution code:
S = input()
lens1 = False
snum = [0]
st = 0
end = 0
count = 1
result = 0

if len(S) == 1:
    result = 1
    lens1 = True
else:
    for i, s in enumerate(S):
        if i == 0:
            if s == '>':
                st = 1
        elif i == len(S) - 1 :
            if s == '<':
                end = 1
            if s != S[i-1]:
                snum.append(count)
                snum.append(1)
            else:
                snum.append(count+1)
        elif s != S[i-1]:
            snum.append(count)
            count = 1
        else:
            count += 1

snum.append(0)

print(snum)

if not lens1:
    for i in range(1, len(snum)-1):
        n = snum[i]
        if st:
            if i % 2 == 0 and n <= snum[i+1]:
                result += int(n * (n - 1) / 2)
            elif i % 2 != 0 and n < snum[i-1]:
                result += int(n * (n - 1) / 2)
            else:
                result += int(n * (n + 1) / 2)
        else:
            if i % 2 == 1 and n <= snum[i+1]:
                result += int(n * (n - 1) / 2)
            elif i % 2 == 0 and n < snum[i-1]:
                result += int(n * (n - 1) / 2)
            else:
                result += int(n * (n + 1) / 2)

print(result)

Submission status: Wrong Answer

Solution code:
import re

s = str(input())

s = re.sub('><', '>,0,<', s)

if s[0] == '<' :
  s = '0,' + str(s)
  
if s[-1] == '>' :
  s = str(s) + ',0'
  
s = re.sub('<>', '<,>', s) 

s = s.split('0')

sum = 0

for i in s:
  i = i.split(',')
  cnt = 0
  for j in range(len(i)):
    Len = int(len(i[j]))
    cnt = cnt + 1
    sum = sum + Len * (Len + 1) / 2
    if cnt > 3:
      des = min([len(i[1]),len(i[2])])
      sum = sum - des
    
print(sum)

Submission status: Wrong Answer

Solution code:
import math
def till_sum(n):
    return((n) * (n - 1) / 2)
s = list(input())
count = 0
ls = []
for i in range(len(s)):
    count += 1
    if len(s) - 1 == i:
        break
    else:
        if s[i] != s[i+1]:
            ls.append(count)
            count = 0
ls.append(count)
print(ls)
result = sum(map(till_sum, ls))
for i in range(math.ceil(len(ls)/2)):
    if len(ls) - 1 == 2*i:
        result += ls[2*i]
    else:
        if ls[2*i] < ls[2*i + 1]:
            result += ls[2*i + 1]
        if ls[2*i] >= ls[2*i + 1]:
            result += ls[2*i]
print(int(result))

Submission status: Wrong Answer

Solution code:
S = str(input())
S += "<"
tmp = ">"
cnt = 0
ans = 0
for i in range(1,len(S)):
    if S[i] != tmp:
        if S[i] == ">":
            cnt += 1
            ans += cnt
        cnt = 0
        tmp = S[i]
    else:
        cnt +=  1
        ans += cnt
        tmp = S[i]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
s = tuple(map(str, input().split("><")))
n = len(s)
ans = 0
def calc(x, y):
    return (x*(x-1) + y*(y-1))/2 + max(x, y)
if n == 1:
    a = s[0].count("<")
    b = s[0].count(">")
    sys.exit()
for i in range(n):
    if i == 0:
        a = s[i].count("<")
        b = s[i].count(">") + 1
    elif i == n - 1:
        a = s[i].count("<") + 1
        b = s[i].count(">")
    else:
        a = s[i].count("<") + 1
        b = s[i].count(">") + 1
    ans += calc(a, b)

print(int(ans))

Submission status: Wrong Answer

Solution code:
S = list(input())
A = [0] * (len(S)+1)
imos = [0] * (len(S))
for i in range(len(S)):
    if S[i] == '>':
        imos[i] = 1
    else:
        imos[i] = -1
imos += [0]
for i in range(len(S), 0, -1):
    imos[i-1] = max(0, imos[i-1] + imos[i])

for i in range(len(S)):
    if S[i] == '<':
        A[i+1] = max(imos[i+1], A[i]+1)
    else:
        A[i+1] = max(0, min(A[i]-1, imos[i+1]))
print(sum(A))

Submission status: Wrong Answer

Solution code:
s_ = input()
s = [one for one in s_]

cnt = 0
tmp_cnt = 0
save_num = 0
tmp_l = []
for i,one in enumerate(s):
    if i == 0:
        tmp = one
        tmp_cnt = 1
    else:
        if one == tmp:
            tmp_cnt += 1
        else:
            tmp_l.append(tmp_cnt)
            tmp_cnt = 1
            tmp = one
tmp_l.append(tmp_cnt)

cnt = 0
for one in tmp_l:
    cnt += 1/2*one*(one-1)
cnt = int(cnt)
for i in range(int(len(tmp_l)//2)):
    cnt += max(tmp_l[2*i],tmp_l[2*i+1])
    
if len(tmp_l) % 2 != 0:
    if tmp == "<":
        cnt += tmp_l[-1]
    else:
        cnt += 2
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
s = tuple(map(str, input().split("><")))
n = len(s)
print(s)
ans = 0
def calc(x, y):
    return (x*(x-1) + y*(y-1))/2 + max(x, y)
if n == 1:
    a = s[0].count("<")
    b = s[0].count(">")
    sys.exit()
for i in range(n):
    if i == 0:
        a = s[i].count("<")
        b = s[i].count(">") + 1
    elif i == n - 1:
        a = s[i].count("<") + 1
        b = s[i].count(">")
    else:
        a = s[i].count("<") + 1
        b = s[i].count(">") + 1
    ans += calc(a, b)

print(int(ans))

Submission status: Wrong Answer

Solution code:
slist=list(input())
kosu=[]
n=len(slist)
counter=1
for i in range(n-1):
	if slist[i]==slist[i+1]:
		counter+=1
	else:
		kosu.append(counter)
		counter=1
kosu.append(counter)

nagasa=len(kosu)
kotae=0

if slist=="<":
	if nagasa%2==0:
		for i in range(0,nagasa,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
	else:
		for i in range(0,nagasa-1,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		kotae+=kosu[-1]*(kosu[-1]+1)/2
else:
	if nagasa%2!=0:
		for i in range(1,nagasa,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		kotae+=kosu[0]*(kosu[0]+1)/2
	else:
		for i in range(1,nagasa-1,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		kotae+=kosu[0]*(kosu[0]+1)/2
		kotae+=kosu[-1]*(kosu[-1]+1)/2
kotae=int(kotae)
print(kotae)

Submission status: Wrong Answer

Solution code:
#0<3>2>1>0<1<2>0<1<2<3<4<5>2>1>0<1
import math
s = input()
bigger=0
smaller=0
count = 0
for i in range(len(s)-1):
    if (s[i]==">" and s[i+1]=="<"):
        count += (max(bigger,smaller))*((max(bigger,smaller))+1)/2
        count += (min(bigger,smaller)-1)*((min(bigger,smaller)-1)+1)/2 if (min(bigger,smaller)-1)!=0 else 0
        bigger = 0
        smaller = 0
    elif (s[i]=="<" and s[i+1]=="<"):
        bigger += 1
    elif (s[i]=="<" and s[i+1]==">"):
        bigger += 1
        smaller += 1
    elif (s[i]==">" and s[i+1]==">"):
        smaller += 1
count += (max(bigger,smaller))*((max(bigger,smaller))+1)/2
count += (min(bigger,smaller)-1)*(min(bigger,smaller))/2 if smaller!=0 else True

print(int(count))

Submission status: Wrong Answer

Solution code:
def p(num):
  # 変数初期化
  count = 1
  result = ''
  max_count = 0
	# 配列全体のループ
  for i in range(len(num)):
    try:
        if num[i] == num[i+1]:
           count = count + 1
        else:
            result = result + str(num[i]) + str(count)
            if max_count < count:
              max_count = count
            count = 1
    except:
          # 最後の文字セットがOutOfRangeになるので結果に出力
          result = result + str(num[i]) + str(count)
  return result, max_count

S = input()
S, _ = p(S)
pre = 0
count =0
for i in range(int(len(S)/2)):

  if S[i*2] == ">":
    n = int(S[i*2+1])
    sum_ = int(n*(n+1)/2)
    count += sum_

    
    count -= min(pre,n)
 
  elif S[i*2] == "<":
    n = int(S[i*2+1])
    sum_ = int(n*(n+1)/2)
    count += sum_
    pre = n


print(count)

Submission status: Wrong Answer

Solution code:
import math
def till_sum(n):
    return((n) * (n - 1) / 2)
s = list(input())
count = 0
ls = []
for i in range(len(s)):
    count += 1
    if len(s) - 1 == i:
        break
    else:
        if s[i] != s[i+1]:
            ls.append(count)
            count = 0
ls.append(count)
result = sum(map(till_sum, ls))
for i in range(math.ceil(len(ls)/2)):
    if len(ls) - 1 == 2*i:
        result += ls[2*i]
    else:
        if ls[2*i] < ls[2*i + 1]:
            result += ls[2*i + 1]
        if ls[2*i] > ls[2*i + 1]:
            result += ls[2*i]
print(int(result))

Submission status: Wrong Answer

Solution code:
S = input()

N = len(S) + 1
L = [-1]
counter = 0

for n in range(N-2):
    counter += 1
    if S[n]!=S[n+1]:
        L.append(counter)
        counter = 0
        if S[n]=='>' and L[-1]>=L[-2]:
            L[-2] -= 1
        elif S[n]=='>' and L[-1]<L[-2]:
            L[-1] -= 1
            
L.append(counter+1)
        
print(sum([l*(l+1)//2 for l in L[1:]]))

Submission status: Wrong Answer

Solution code:
S = str(input())
N = len(S) + 1
a = [0]*N
if '>' not in S or '<' not in S:
    print(N*(N+1)//2)
    exit()
res = 0
st = 1
if S[0] == '>':
    st = S.index('<')
    res += st*(st+1)//2
ed = 0
a = 0
b = 0
for i in range(st, N-1):
    if S[i-1] == '>' and S[i] == '<':
        if i != st:
            res += max([a+1,b]) + a*(a+1)//2 + b*(b-1)//2
        if i==N-2:
            ed = -2
            break
        a = 0
        b = 0
        ed = i
    elif i==N-2 and S[i] == '>':
        res += max([a+1,b+1]) + a*(a+1)//2 + b*(b+1)//2
        ed = i
    elif S[i] == '<':
        a += 1
    elif S[i] == '>':
        b += 1
if ed == -2:
    res += 1
elif ed != N-2:
    res += (N-1-ed)*(N-ed)//2
print(res)

Submission status: Wrong Answer

Solution code:
import math

S = input()
pad = []
left_flag = S[0] == "<"
count = 0
for k in S:
    if left_flag and k == "<":
        count += 1
    elif left_flag and k == ">":
        pad.append(count)
        left_flag ^= 1
        count = 1
    elif (not left_flag) and k == ">":
        count += 1
    else:
        pad.append(-count)
        left_flag ^= 1
        count = 1
if left_flag:
    pad.append(count)
else:
    pad.append(-count)


result = 0
for i, j in zip(pad[0::2], pad[1::2]):
    if i > abs(j):
        result += sum(range(i + 1)) + sum(range(abs(j)))
    else:
        result += sum(range(i)) + sum(range(abs(j) + 1))
if len(pad) % 2 == 1:
    result += sum(range(abs(pad[-1] + 1)))
print(result)

Submission status: Wrong Answer

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

s = str(input())

s_length = len(s)

answer = 0
cnt = 0
t = 0
_t = 0
for i in range(s_length):
  if s[i] == '<':
    t += 1
    cnt = 0
    answer += t
  else:
    if t == 0:
      if _t <= cnt:
        t = 0
        cnt += 1
        answer += cnt 
      else:
        t = 0
        cnt += 1
        answer += cnt - 1
    else:
      _t = t
      t = 0
      answer += cnt * 1
      cnt += 1
      

print(answer)

Submission status: Wrong Answer

Solution code:
s = list(input())

memo = ""
cnt = 0
before_cnt = 0
ans = 0

for x in s:
    if memo == "":
        memo = x
    
    if memo == x:
        cnt += 1
    else:
        ans += cnt * (cnt+1) // 2
        if before_cnt < cnt:
            if memo == ">":
                ans -= before_cnt
        else:
            if memo == ">":
                ans -= cnt
        before_cnt = cnt
        cnt = 1
        memo = x
else:
    ans += cnt * (cnt+1) // 2
    if before_cnt < cnt:
        if memo == ">":
            ans -= before_cnt
    before_cnt = cnt
    cnt = 0

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
#print(len(S))
s_list = []
head_num = 10**6 if S[0] == ">" else 0
s_list.append(head_num)
for i in range(len(S)-1):
    if S[i] == ">" and S[i+1] == "<":
        s_list.append(0)
    elif S[i] == "<":
        s_list.append(s_list[i]+1)
    else:
        s_list.append(s_list[i]-1)
if S[len(S)-1] == "<":
    s_list.append(s_list[len(S)-1] +1)
else:
    s_list.append(s_list[len(S)-1] -1)

#print(s_list)
count = 1
for i in range(len(S)-1,-1,-1):
    if S[i] == ">" and S[i-1] == ">":
        s_list[i] = count
        count += 1
    else:
        count = 1
#print(len(s_list))
#print(s_list)

sum = 0
for i in range(len(s_list)):
    sum += s_list[i]

print(sum)

Submission status: Wrong Answer

Solution code:
import math

S = input()
pad = []
left_flag = S[0] == "<"
count = 0
for k in S:
    if left_flag and k == "<":
        count += 1
    elif left_flag and k == ">":
        pad.append(count)
        left_flag ^= 1
        count = 1
    elif (not left_flag) and k == ">":
        count += 1
    else:
        pad.append(-count)
        left_flag ^= 1
        count = 1
if left_flag:
    pad.append(count)
else:
    pad.append(-count)


result = 0
for i, j in zip(pad[0::2], pad[1::2]):
    if i > abs(j):
        result += sum(range(i + 1)) + sum(range(abs(j)))
    else:
        result += sum(range(i)) + sum(range(abs(j) + 1))
if len(pad) % 2 == 1:
    result += sum(range(abs(pad[-1])))
print(result)

Submission status: Wrong Answer

Solution code:
S = input()

N = len(S) + 1
L = [-1]
counter = 0

for n in range(N-2):
    counter += 1
    if S[n]!=S[n+1]:
        L.append(counter)
        counter = 0
        if S[n]=='>' and L[-1]>=L[-2]:
            L[-2] -= 1
        elif S[n]=='>' and L[-1]<L[-2]:
            L[-1] -= 1
            
if S[-1]=='<':
    L.append(counter+1)
else:
    L.append(counter)
        
print(sum([l*(l+1)//2 for l in L[1:]]))

Submission status: Wrong Answer

Solution code:
import math

S = input()
pad = []
left_flag = S[0] == "<"
count = 0
for k in S:
    if left_flag and k == "<":
        count += 1
    elif left_flag and k == ">":
        pad.append(count)
        left_flag ^= 1
        count = 1
    elif (not left_flag) and k == ">":
        count += 1
    else:
        pad.append(-count)
        left_flag ^= 1
        count = 1
if left_flag:
    pad.append(count)
else:
    pad.append(-count)


result = 0
for i, j in zip(pad[0::2], pad[1::2]):
    if i > abs(j):
        result += sum(range(i + 1)) + sum(range(abs(j)))
    else:
        result += sum(range(i)) + sum(range(abs(j) + 1))
if len(pad) % 2 == 1:
    result += sum(range(pad[-1]))
print(result)

Submission status: Wrong Answer

Solution code:
S = list(input())
A = [0] * (len(S)+1)
imos = [0] * (len(S))
for i in range(len(S)):
    if S[i] == '>':
        imos[i] = 1
    else:
        imos[i] = -1
for i in range(len(S)-1, 0, -1):
    imos[i-1] += max(0, imos[i])

imos += [0]

for i in range(len(S)):
    if S[i] == '<':
        A[i+1] = max(imos[i+1], A[i]+1)
    else:
        A[i+1] = max(0, min(A[i]-1, imos[i+1]))
print(sum(A))

Submission status: Wrong Answer

Solution code:
s=list(input())
count=0
count1=0
ans=0
for i in range(len(s)):
    if s[i]=='<' and i==len(s)-1:
        count+=1
        ans+=count*(count+1)//2
    elif s[i]=='>' and i==len(s)-1:
        count1+=1
        ans+=count1*(count1+1)//2
    if count>0 and s[i]=='>':
        if count==1:
            count=0
            count1+=1
            continue
        else:
            if i==len(s)-1:
                ans+=(count-1)*count//2
                count=0
                count1+=1
               # print(ans)
                continue
            else:
                ans+=(count+1)*count//2
                count=0
                count1+=1
                #print(ans)
                continue
    elif count1>0 and s[i]=='<':
        if count1==1:
            count1=0
            count+=1
            continue
        else:
            if i==len(s)-1:
                ans+=(count1-1)*count1//2
                count1=0
                count+=1
                #print(ans)
                continue
            else:
                ans+=(count1+1)*count1//2
                count1=0
                count+=1
                #print(ans)
                continue
        #------------------------------------------
    if s[i]=='<':
        count+=1
    else:
        count1+=1
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) + 1
lis = [0] * n
if s[0] == "<":
  lis[0] = 0
p = 1
while p < n - 1:
  if s[p - 1] == ">" and s[p] == "<":
    lis[p] = 0
  elif s[p - 1] == "<" and s[p] == "<":
    lis[p] = max(lis[p - 1] + 1, lis[p])
  elif s[p] == ">":
    pass
  p += 1
    
if s[-1] == ">":
  lis[-2] = 1
  lis[-1] = 0
  
p = n - 3
while p >= 0:
  if s[p] == ">" and s[p + 1] == "<":
    if p - 1 >= 0:
      lis[p] = max(lis[p + 1] + 1, lis[p], lis[p - 1] + 1)
    else:
      lis[p] = 1
  elif s[p] == ">" and s[p + 1] == ">":
    if p - 1 >= 0:
      lis[p] = max(lis[p + 1] + 1, lis[p], lis[p - 1] + 1)
    else:
      lis[p] = max(lis[p + 1] + 1, lis[p])
  elif s[p] == "<":
    pass
  p -= 1

if s[-1] == "<":
  lis[-1] = lis[-2] + 1
  
#print(sum(lis))
print(lis)