TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
#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 += math.factorial(min(bigger,smaller)-1) if smaller!=0 else True

print(int(count))


#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))/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 (min(bigger,smaller)-1)!=0 else 0

print(int(count))



Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

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)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

s = input()

total = 0
tmp_current = 0
tmp_high = float('inf')
count_from_high = 1
flag_current = False # '<':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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
s = list(input())
data = [0] * (len(s) + 1)
for i in range(len(s)):
    if s[i] == "<":
        data[i + 1] = data[i] + 1

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

s = list(input())
data = [0] * (len(s) + 1)
for i in range(len(s)):
    if s[i] == "<":
        data[i + 1] = data[i] + 1

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
S = list(map(str, input()))
N = len(S)+1
List = [0]*N
rightcount = 0
leftcount = 0

if S[0] == "<":
    leftcount+=1
else:
    rightcount+=1

for i in range(1, N-1):
    if S[i] == "<":
        leftcount+=1
        if S[i-1] == "<":
            List[i] = List[i-1]+1
        elif S[i-1] == ">":
            for j in range(rightcount):
                List[i-j] = j
            if List[i-rightcount]<=List[i-rightcount+1]:
                List[i-rightcount] = List[i-rightcount+1] + 1
            rightcount = 0


    if S[i] == ">":
        rightcount+=1
        if S[i-1] =="<":
            for j in range(leftcount+1):
                List[i-j] = leftcount - j
            leftcount = 0

if S[N-2] == "<":
    List[N-1] = List[N-2] + 1
else:
    for j in range(rightcount):
        List[N-1-j] = j
    if List[N-1-rightcount]<=List[N-1-rightcount+1]:
        List[N-1-rightcount] = List[N-1-rightcount+1] + 1

print(List)
print(sum(List))


S = list(map(str, input()))
N = len(S)+1
List = [0]*N
rightcount = 0
leftcount = 0

if S[0] == "<":
    leftcount+=1
else:
    rightcount+=1

for i in range(1, N-1):
    if S[i] == "<":
        leftcount+=1
        if S[i-1] == ">":
            for j in range(rightcount):
                List[i-j] = j
            if List[i-rightcount]<List[i-rightcount+1]:
                List[i-rightcount] = List[i-rightcount+1] + 1
            rightcount = 0


    if S[i] == ">":
        rightcount+=1
        if S[i-1] =="<":
            for j in range(leftcount+1):
                List[i-j] = leftcount - j
            leftcount = 0

if S[N-2] == "<":
    List[N-1] = 1
else:
    for j in range(rightcount):
        List[N-j] = j
    if List[N-rightcount]<List[N-rightcount+1]:
        List[N-rightcount] = List[N-rightcount+1] + 1

print(sum(List))

S = list(map(str, input()))
N = len(S)+1
List = [0]*N
rightcount = 0
leftcount = 0

if S[0] == "<":
    leftcount+=1
else:
    rightcount+=1

for i in range(1, N-1):
    if S[i] == "<":
        leftcount+=1
        if S[i-1] == "<":
            List[i] = List[i-1]+1
        elif S[i-1] == ">":
            for j in range(rightcount):
                List[i-j] = j
            if List[i-rightcount]<=List[i-rightcount+1]:
                List[i-rightcount] = List[i-rightcount+1] + 1
            rightcount = 0


    if S[i] == ">":
        rightcount+=1
        if S[i-1] =="<":
            for j in range(leftcount+1):
                List[i-j] = leftcount - j
            leftcount = 0

if S[N-2] == "<":
    List[N-1] = List[N-2] + 1
else:
    for j in range(rightcount):
        List[N-1-j] = j
    if List[N-1-rightcount]<=List[N-1-rightcount+1]:
        List[N-1-rightcount] = List[N-1-rightcount+1] + 1

print(sum(List))


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
s = input()
l, count = [], 0
for i in s:
    if i=='>': count+=1
    else:
        if count: l.append(count)
        count = 0
if count: l.append(count); count = 0
j = 0
ans = []
if s[0]=='<':
    ans.append(0)
    for i in range(len(s)):
    if s[i]=='<': ans.append(ans[-1]+1)
    else:
        if l[j]==0: j+=1
        if ans[-1]>=l[j]:
            l[j]-=1
            ans.append(l[j])
                
        else:
            ans[-1]=l[j]
            l[j]-=1
            ans.append(l[j])
    print(sum(ans))

else:
    ans.append(l[j])
    l[j]-=1
    for i in range(len(s)):
    if s[i]=='<': ans.append(ans[-1]+1)
    else:
        if l[j]==0: j+=1
        if j<len(l):
            
            if ans[-1]>=l[j]:
                ans.append(l[j])
                l[j]-=1
                
                    
            else:
                ans[-1]=l[j]
                ans.append(l[j])
                l[j]-=1
                
        else: ans.append(0)
    print(sum(ans))


s = input()
l, count = [], 0
for i in s:
    if i=='>': count+=1
    else:
        if count: l.append(count)
        count = 0
if count: l.append(count); count = 0
j = 0
ans = []
if s[0]=='<': ans.append(0)
else:
    ans.append(l[0])
    l[0]-=1

for i in range(len(s)):
    if s[i]=='<': ans.append(ans[-1]+1)
    else:
        if i==0: ans.append(ans[-1]-1); continue
        if l[j]==0: j+=1
        if ans[-1]>=l[j]:
            l[j]-=1
            ans.append(l[j])
                
        else:
            ans[-1]=l[j]
            l[j]-=1
            ans.append(l[j])
print(sum(ans))


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
S = input()
d = []
lt = 0
gt = 0
for i in range(len(S)):
    if i == 0:
        continue
    if S[i - 1]  == S[i] and S[i] == "<":
        lt += 1
    if S[i - 1] == S[i] and S[i] == ">":
        gt += 1
    if S[i - 1] != S[i] and S[i-1] == "<":
        d.append("<" * (lt + 1))
        lt = 0
    if S[i - 1] != S[i] and S[i - 1] == ">":
        d.append(">" * (gt + 1))
        gt = 0
    if i == len(S) - 1 and S[i] == "<":
        d.append("<" * (lt + 1))
    if i == len(S) - 1 and S[i] == ">":
        d.append(">" * (gt + 1))
    
print(d)
ans=0

if d[0][0] == "<":
    i = 0
    while i < len(d) - 1:
        if i != len(d) - 1:
            if len(d[i]) >= len(d[i + 1]):
                for i in range(1, len(d[i])+1):
                    ans += i
                for i in range(1, len(d)):
                    ans += i
                i += 2
            elif len(d[i]) < len(d[i + 1]):
                for i in range(1, len(d[i])+1):
                    ans += i
                for i in range(1, len(d)):
                    ans += i
                i+= 2
        elif i  == len(d) - 1:
            for i in range(1, len(d[i])+1):
                ans += i
                i += 1

if d[0][0] ==">":
    ans += (len(d[i]) + 1) * len(d[i]) / 2
    i = 1
    while i < len(d) - 1:
        if i != len(d) - 1:
            if len(d[i]) >= len(d[i + 1]):
                ans += (len(d[i]) + 1) * len(d[i]) / 2 + (len(d[i+1])) * len(d[i + 1]) / 2
                i += 2
            elif len(d[i]) < len(d[i + 1]):
                ans += (len(d[i])) * len(d[i]) / 2 + (len(d[i+1])+1) * len(d[i + 1]) / 2
                i += 2
        elif i  == len(d) - 1:
            ans +=  (len(d[i]) + 1) * len(d[i]) / 2

print(ans)
    

                

        
# min_d = 0

#     min_d = min(min_d, d[i])

# d = list(map(lambda x: x + abs(min_d), d))

# if S[0] == "<":
#     d[0] = 0

# ans = 0

#     ans += d[i]
# print(d)
# print(ans)
            

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,-1,-1):
    if S[i] == ">":
        a[i] = max(a[i], a[i+1] + 1)
        
print(sum(a))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#
import sys
import math
import numpy as np
import itertools


s = list(input())
t = [0]
now = 0
for i in range(len(s)):
    print(i,t)
    if s[i]=='<':
        now += 1
        t.append(now)
    elif now == 0:
        now = -1
        t.append(now)
        if now == -1:
            t[i+1] += 1
            now += 1
            for j in range(i,-1,-1):
                if t[j]==t[j+1]:
                    t[j] += 1
                else:
                    break
    else:
        now = 0
        t.append(now)

answer=0
for i in range(len(t)):
    answer += t[i]

print(answer)



#
import sys
import math
import numpy as np
import itertools


s = list(input())
t = [0]
now = 0
for i in range(len(s)):
#    print(i,t)
    if s[i]=='<':
        now += 1
        t.append(now)
    elif now == 0:
        now = -1
        t.append(now)
        if now == -1:
            t[i+1] += 1
            now += 1
            for j in range(i,-1,-1):
                if j==0:
                    t[j]=0
                elif t[j]==t[j+1]:
                    t[j] += 1
                else:
                    break
    else:
        now = 0
        t.append(now)

answer=0
for i in range(len(t)):
    answer += t[i]

print(t,answer)



#
import sys
import math
import numpy as np
import itertools


s = list(input())
t = [0]
now = 0
if s[0]=='<':
    now = 1
else:
    now = -1

for i in range(1,len(s)):
    if s[i]=='<' and now > 0:
        now += 1
    elif s[i]=='<' and now < 0:
        t.append(now)
        now = 1
    elif s[i]=='>' and now < 0:
        now -= 1
    elif s[i]=='>' and now > 0:
        t.append(now)
        now = -1
t.append(now)

answer=0
for i in range(1,len(t)):
    if t[i-1] > 0 and t[i] < 0:
        if t[i-1] < -t[i]:
            t[i-1] -= 1
        else:
            t[i] += 1
for i in range(len(t)):
    answer += abs(t[i]) * (abs(t[i]) + 1) // 2
#print(t)
print(answer)



Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
s=input()
n=len(s)
lst=[]
cnt=1

if n==2:
  print(1)
  
for i in range(n-2):
  if s[i]==s[i+1]:
    cnt+=1
  else:
    lst.append(cnt)
    cnt-=(cnt-1)
    
totl=0
l=len(lst)
if s[0]=='<':
  for j in range(l):
    if j%2==0:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
else:
  totl+=lst[0]
  for j in range(len(lst)):
    if j%2==1:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)

      
      
      
      
      
  


s=input()
lst=[]
cnt=1
for i in range(n-2):
  if s[i]=s[i+1]:
    cnt+=1
  else:
    lst.append(cnt)
    cnt-=(cnt-1)
totl=0
if s[0]=='<':
  for j in range(len(lst)):
    if j%2==0:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,len(lst)-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
else:
  totl+=lst[0]
  for j in range(len(lst)):
    if j%2==1:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,len(lst)-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)

      
      
      
      
      
  


s=input()
n=len(s)
lst=[]
cnt=1

if n==2:
  print(1)
  
for i in range(n-2):
  if s[i]=s[i+1]:
    cnt+=1
  else:
    lst.append(cnt)
    cnt-=(cnt-1)
totl=0
if s[0]=='<':
  for j in range(len(lst)):
    if j%2==0:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,len(lst)-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
else:
  totl+=lst[0]
  for j in range(len(lst)):
    if j%2==1:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,len(lst)-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)

      
      
      
      
      
  


s=input()
n=len(s)
lst=[]
cnt=1

if n==2:
  print(1)
  
for i in range(n-1):
  if s[i]==s[i+1]:
    cnt+=1
  else:
    lst.append(cnt)
    cnt-=(cnt-1)

if s[n-2]!=s[n-1]:
  lst.append(1)
else:
  lst.append(cnt)
    
totl=0
l=len(lst)
if s[0]=='<':
  for j in range(l):
    if j%2==0:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
else:
  totl+=lst[0]
  for j in range(len(lst)):
    if j%2==1:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)

      
      
      
      
      
  


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
S = input()
ans = 0
S = S.repace("><"/, ">,<").split(",")
for s in S:
  a = s.count(">")
  b = s.count("<")
  ans += a * (a - 1) // 2 + b * (b - 1) // 2 + max(a, b)
print(ans)

S = input().replace("><", ">,<").split(",")
ans = 0
for s in S:
    n = s.count("<")
    m = s.count(">")
    ans += (n * (n - 1)) // 2 + (m * (m - 1)) // 2 + max(n, m)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
S = input()
ans = 0
a = []
up = True
count = 0
for i in S:
    if up:
        if i == '>':
            a.append(count)
            count = 1
            up = False
        else:
            count += 1
    else:
        if i == '<':
            a.append(count)
            count = 1
            up = True
        else:
            count += 1
a.append(count)
a.append(0)
for i in range(0,len(a),2):
    u,d = max(a[i],a[i+1]), min(a[i],a[i+1])-1
    ans += u*(u+1)//2 + d*(d+1)//2
print(ans)
    

S = input().replace('><','> <').split()
ans = 0
for s in S:
    up = s.count('<')
    down = len(s)-up
    if up < down:
        up -= 1
        ans += up*(up+1)//2 + down*(down+1)//2
    else:
        down -= 1
        ans += up*(up+1)//2 + down*(down+1)//2        
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
S = str(input())
S += "<"
l = 0
r = 0
ans = 0
tmp = ">"
for i in range(len(s)):
    if tmp == ">" and S[i] == "<":
        ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) - 1
        l = 1
        r = 0
        tmp = S[i]
    else:
        if S[i] == ">":
            r += 1
        else:
            l += 1
        tmp = S[i]
print(ans)

S = str(input())
l = 0
r = 0
ans = 0
tmp = S[0]
if tmp == ">":
    r = 1
else:
    l = 1
for i in range(1,len(S)):
    if tmp == ">" and S[i] == "<":
        ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) * (min(l, r) - 1) / 2
        l = 1
        r = 0
        tmp = S[i]
    else:
        if S[i] == ">":
            r += 1
        else:
            l += 1
        tmp = S[i]
ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) * (min(l, r) - 1) / 2
print(int(ans))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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
print(S)
print(list)
for i in range(len(S)):
	if S[i] == ">" and S[i+1] == "<":
		list[i+1] = 0
		cnt = 1
	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))

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		
if S[0] == ">":
	list[0] = list[1] + 1
#print(list)
print(sum(list))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

s = str(input())
#s = "<>>><<><<<<<>>><"
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)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

s = str(input())
l = []
t = 0
for i in range(1,len(s)):
    if s[i] != s[i-1]:
        l.append(s[t:i])
        t = i
else:
    l.append(s[t:len(s)])


def calc(n):
    tmp = 0
    for i in range(1,n+1):
        tmp += i
    return tmp

left = 0
right = 0
ans = 0

for i,sg in enumerate(l):
    if sg[0]=='>':
        if len(sg)>=left:
            ans += calc(len(sg))
        else:
            ans += calc(len(sg)-1)
        right = len(sg)
    else:
        if len(sg)>=right or i!=len(l)-1:
            ans += calc(len(sg))
        else:
            ans += calc(len(sg)-1)
        left = len(sg)

print(ans)


s = str(input())
l = []
t = 0
for i in range(1,len(s)):
    if s[i] != s[i-1]:
        l.append(s[t:i])
        t = i
else:
    l.append(s[t:len(s)])


def calc(n):
    tmp = 0
    for i in range(1,n+1):
        tmp += i
    return tmp

left = 0
right = 0
ans = 0

for i,sg in enumerate(l):
    if sg[0]=='>':
        if left < len(sg):
            ans -= left
            ans += calc(len(sg))
        else:
            ans += calc(len(sg)-1)
    else:
        ans += calc(len(sg))
        left = len(sg)

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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))

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
S = input()

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

print(ans)

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


S = input()

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

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
S = input()
res = [0]*(len(S)+1)


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

0

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


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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
S = list(input())

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


S = list(input())

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

S = list(input())

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


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

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


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

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


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

from_left = [0] * N
from_right = [0] * N

for i in range(N-1):
  s = S[i]
  if s == '<':
    from_left[i+1] = from_left[i] + 1

for i in range(N-2,-1,-1):
  s = S[i]
  if s == '>':
    from_right[i] = from_right[i+1] + 1
    
ans = 0
for i in range(N):
  ans += max(from_left[i],from_right[i])
  
print(ans)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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))


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

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(">")
    print(int(calc(a, b)))
    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))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
sys.setrecursionlimit(5000000000)

s = input()
cont_list = []
ini_di = s[0]
count = 1
for i in range(1, len(s)):
    if s[i] == s[i-1]:
        count += 1
        if i == len(s) - 1:
            cont_list.append(count)
    else:
        cont_list.append(count)
        count = 1
        if i == len(s) - 1:
            cont_list.append(count)


def counting(i):
    a = max(cont_list[i], cont_list[i + 1])
    b = min(cont_list[i], cont_list[i + 1])
    return (1 + a) * a / 2 + b * (b - 1) / 2


if ini_di == "<":
    count2 = 0
    if len(cont_list) % 2 == 0:
        for i in range(0, len(cont_list), 2):
            count2 += int(counting(i))
    else:
        for i in range(0, len(cont_list)-1, 2):
            count2 += int(counting(i))
        las = cont_list[len(cont_list)-1]
        count2 += int((1+las)*las/2)
    print(count2)
else:
    count2 = 0
    if len(cont_list) % 2 == 1:
        ini = cont_list[0]
        count2 += int((1+ini)*ini/2)
        for i in range(1, len(cont_list), 2):
            count2 += int(counting(i))
    else:
        ini = cont_list[0]
        count2 += int((1 + ini) * ini / 2)
        las = cont_list[len(cont_list) - 1]
        count2 += int((1 + las) * las / 2)
        for i in range(1, len(cont_list)-1, 2):
            count2 += int(counting(i))
    print(count2)


import sys
sys.setrecursionlimit(5000000)

s = input()
if len(s) == 1:
    print("1")
    exit()
cont_list = []
ini_di = s[0]
count = 1
for i in range(1, len(s)):
    if s[i] == s[i-1]:
        count += 1
        if i == len(s) - 1:
            cont_list.append(count)
    else:
        cont_list.append(count)
        count = 1
        if i == len(s) - 1:
            cont_list.append(count)


def counting(i):
    a = max(cont_list[i], cont_list[i + 1])
    b = min(cont_list[i], cont_list[i + 1])
    return (1 + a) * a / 2 + b * (b - 1) / 2


if ini_di == "<":
    count2 = 0
    if len(cont_list) % 2 == 0:
        for i in range(0, len(cont_list), 2):
            count2 += int(counting(i))
    else:
        for i in range(0, len(cont_list)-1, 2):
            count2 += int(counting(i))
        las = cont_list[len(cont_list)-1]
        count2 += int((1+las)*las/2)
    print(count2)
else:
    count2 = 0
    if len(cont_list) % 2 == 1:
        ini = cont_list[0]
        count2 += int((1+ini)*ini/2)
        for i in range(1, len(cont_list), 2):
            count2 += int(counting(i))
    else:
        ini = cont_list[0]
        count2 += int((1 + ini) * ini / 2)
        las = cont_list[len(cont_list) - 1]
        count2 += int((1 + las) * las / 2)
        for i in range(1, len(cont_list)-1, 2):
            count2 += int(counting(i))
    print(count2)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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] = -10000000
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))
print(A)
print(imos)


import numpy as np

S = list(input())
l = len(S) + 1
A = [0] * l
B = [0] * l

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

for i in range(len(S)-1, -1, -1):
    if S[i] == '>':
        B[i] = B[i+1] + 1
answer = 0
for i in range(l):
    answer += max(A[i], B[i])
print(answer)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys

def solve():
    S = input()
    N = len(S)
    A = [0] * (N + 1)
    init = []
    for i in range(N - 1):
        if  S[i] == ">" and S[i + 1] == "<": init.append(i + 1)
    #right
    if S[0] == "<":
        for i in range(N):
            if S[i] == ">": break
            A[i+1] = A[i] + 1

    for s in init:
        d = s + 1
        A[d] = A[d - 1] + 1
        while d <= N - 1:
            if S[d] == ">": break
            d += 1
            A[d] = A[d-1] + 1
    print(A)
    #left
    if S[N - 1] == ">":
        for i in reversed(range(N)):
            if S[i] == "<": break
            A[i] = A[i + 1] + 1
            
    for s in init:
        d = s - 1
        while d >= 0:
            if S[d] == "<": break
            A[d] = max(A[d], A[d+1] + 1)
            d -= 1

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

    return 0

if __name__ == "__main__":
    solve()

import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    N = len(S)
    A = [0] * (N + 1)
    Start = []
    if S[0] == "<": Start.append(0)
    for i in range(N - 1):
        if S[i] == ">" and S[i+1] == "<": Start.append(i + 1)
    if S[N-1] == ">": Start.append(N)
    for s in Start:
        if s < N:
            for r in range(s, N):
                if S[r] == ">": break
                else: A[r + 1] = max(A[r + 1], A[r] + 1)
    for s in Start:
        if s > 0:
            for r in reversed(range(1, s + 1)):
                if S[r - 1] == "<": break
                else: A[r - 1] = max(A[r - 1], A[r] + 1)
    #print(A)
    print(sum(A))
    #print(Start)

    
    
    return 0

if __name__ == "__main__":
    solve()



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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
        


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


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

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,-1,-1):
    if S[j] == ">":
        lis[j] = max(lis[j],lis[j+1] + 1)
 
 
 
print(sum(lis))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

s=str(input())
s=list(s)
temp=[]
cnt=0
ans=0
for i in range(len(s)):
  if s[i]=="<":
    if i!=0 and s[i-1]==">":
      temp.append(cnt)
      cnt=0
    cnt=cnt+1
  else:
    if i!=0 and s[i-1]=="<":
      temp.append(cnt)
      cnt=0
    cnt=cnt+1
temp.append(cnt)
if s[0]=="<":
  for i in range(0,len(temp)-1,2):
    tempmin=min(temp[i],temp[i+1])-1
    tempmax=max(temp[i],temp[i+1])
    temp[i]=tempmin
    temp[i+1]=tempmax
else:
  for i in range(1,len(temp)-1,2):
    tempmin=min(temp[i],temp[i+1])-1
    tempmax=max(temp[i],temp[i+1])
    temp[i]=tempmin
    temp[i+1]=tempmax
for i in range(len(temp)):
  ans=ans+temp[i]*(temp[i]+1)//2
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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))

S=input()
x=len(S)
temp=ans=check=0
for i in range(x):
  if S[i]=="<":
    if temp>0 and S[i-1]==">":
      ans=ans-(temp*check)
      temp=0    
    check=0
    temp+=1
    ans+=temp
  else:
    check+=1
    temp-=1
    if temp<0:
      temp=0
      ans+=check
    else:
      ans+=temp
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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


Verdicts: Runtime Error

Accepted