TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi is at an all-you-can-eat restaurant.  The restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.  The restaurant has the following rules:    * You can only order one dish at a time. The dish ordered will be immediately served and ready to eat.   * You cannot order the same kind of dish more than once.   * Until you finish eating the dish already served, you cannot order a new dish.   * After T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.  Let Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.  What is the maximum possible happiness achieved by making optimal choices?

Submission attempts (in order):
import numpy as np
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    n, t = map(int, input().split())
    dp = np.zeros(t,dtype=int)
    food = []
    for _ in range(n):
        a, b = map(int, input().split())
        food.append([a, b])
    food.sort(key=lambda x: x[0]*-1)
    for j in range(n):
        a, b = food[j][0], food[j][1]
        dptmp=np.zeros(t,dtype=int)
        dptmp[a:] = np.maximum(dp[a:],dp[:-a]+b)
        dptmp[:a] = np.maximum(np.full(a,b,dtype=int), dp[:a])
        dp=dptmp
    print(dp[-1])


if __name__ == '__main__':
    main()

import numpy as np
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    n, t = map(int, input().split())
    dp = np.zeros(t,dtype=int)
    food = []
    for _ in range(n):
        a, b = map(int, input().split())
        food.append([a, b])
    food.sort(key=lambda x: x[0]*-1)
    for j in range(n):
        a, b = food[j][0], food[j][1]
        a=min(a,t)
        dptmp=np.zeros(t,dtype=int)
        dptmp[a:] = np.maximum(dp[a:],dp[:-a]+b)
        dptmp[:a] = np.maximum(np.full(a,b,dtype=int), dp[:a])
        dp=dptmp
    print(dp[-1])


if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: Takahashi is at an all-you-can-eat restaurant.  The restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.  The restaurant has the following rules:    * You can only order one dish at a time. The dish ordered will be immediately served and ready to eat.   * You cannot order the same kind of dish more than once.   * Until you finish eating the dish already served, you cannot order a new dish.   * After T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.  Let Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.  What is the maximum possible happiness achieved by making optimal choices?

Submission attempts (in order):
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, T = map(int, readline().split())
m = map(int, read().split())
AB = sorted(zip(m, m))

dp = np.zeros(T, np.int64)

ans = 0
table = np.zeros(T, int)
for a, b in AB:
    ans = max(ans, max(table) + b)
    np.maximum(table[:-a] + b, table[a:], out=table[a:])
    print(table)
print(ans)


import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, T = map(int, readline().split())
m = map(int, read().split())
AB = sorted(zip(m, m))

dp = np.zeros(T, np.int64)

ans = 0
table = np.zeros(T, int)
for a, b in AB:
    ans = max(ans, max(table) + b)
    np.maximum(table[:-a] + b, table[a:], out=table[a:])
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is at an all-you-can-eat restaurant.  The restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.  The restaurant has the following rules:    * You can only order one dish at a time. The dish ordered will be immediately served and ready to eat.   * You cannot order the same kind of dish more than once.   * Until you finish eating the dish already served, you cannot order a new dish.   * After T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.  Let Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.  What is the maximum possible happiness achieved by making optimal choices?

Submission attempts (in order):
N,T=map(int,input().split())
d=[None]*N
for i in range(N):
  a,b=map(int,input().split())
  d[i]=[a,b]

dp=[-1]*(30*2)
dp[0]=0
for i in range(len(d)):
  for j in range(T,-1,-1):
    if dp[j]!=-1:
      if dp[j]+d[i][1]>dp[j+d[i][0]]:
        dp[j+d[i][0]]=dp[j]+d[i][1]
      
print(max(dp))

N,T=map(int,input().split())
d=[None]*N
for i in range(N):
  a,b=map(int,input().split())
  d[i]=[a,b]

d=sorted(d,key=lambda x:x[a])
dp=[-1]*(3000*2+5)
dp[0]=0
for i in range(len(d)):
  for j in range(T-1,-1,-1):
    if dp[j]!=-1:
      if dp[j]+d[i][1]>dp[j+d[i][0]]:
        dp[j+d[i][0]]=dp[j]+d[i][1]
      
print(max(dp))

N,T=map(int,input().split())
import numpy as np
dp=np.zeros(T,dtype=int)
maxval=0

meals=[None]*N
for i in range(N):
  a,b=map(int,input().split())
  meals[i]=a,b

meals=sorted(meals,key=lambda x:x[0])

for i in range(N):
  a,b=meals[i]
  if maxval<dp[-1]+b:
    maxval=dp[-1]+b
  np.maximum(dp[:-a]+b,dp[a:],out=dp[a:])
  
print(maxval)

Verdicts: 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()
d=[0]*(len(s)+1)
scount=0
ans=0
x=0
y=0
for i in range(1,len(s)-1):
  if s[i]==">":
    scount+=1
    Z=i
  elif s[i]=="<":
    d[i+1]=d[i]+1
    if scount>1:
      Q=scount
      for j in range(scount):
        d[i-scount+j]=Q
        Q-=1
    scount=0
    
if s[-1]==">":
  scount+=1
    
if scount>1:
  Q=scount
  if scount>d[Z-scount]:
    for j in range(scount):
      d[Z+1-scount+j]=Q
      Q-=1
  else:
    Q-=1
    for j in range(scount):
      d[Z+2-scount+j]=Q
      Q-=1
if s[-1]=="<":
    ans+=d[-1]+1
    scount=0
      
print(d)
print(sum(d)+ans)

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

s=input()
d=[0]*(len(s)+1)
Z=[]
scount=0
ans=0
for i in range(1,len(s)-1):
  if s[i]==">":
    d[i+1]=0
    scount+=1
    Q=scount
    X=i
    if s[i-1]=="<":
      Z.append(i)
  elif s[i]=="<":
    d[i+1]=d[i]+1
    for j in range(scount):
      d[i-scount+j]=(scount-j)
    scount=0

if s[-1]==">":
  d[-1]=0
  scount+=1
  Q=scount
  X=len(s)-1    
if scount>0:
  for j in range(scount):
    d[X-scount+j+1]=Q
    Q-=1
for i in Z:
  d[i]=max(d[i+1]+1,d[i-1]+1)
  if i==0 and s[0]=="<":
    d[i]=0
if s[-1]=="<":
  d[-1]=d[-2]+1
if s[0]==">":
  d[0]=d[1]+1

print(d)

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

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):
from itertools import groupby

r = p = 0
for k, g in groupby(input()):
    r += sum(i for i, _ in enumerate(g, 1))
    if k == '>':
        r -= min(i, p)
    p = i
print(r)


from itertools import groupby, chain

def pairs(t):
    while True:
        x, y = next(t), next(t)
        a =[sum(1 for _ in g) for k, g in (x, y)]
        yield sum(x * (x - 1) // 2 for x in a) + max(a)

s = input()
t = groupby(s)
d = [(0, ())]
if s[0] == '<':
    t = chain(d, t)
if s[-1] == '>':
    t = chain(t, d)
print(sum(pairs(t)))



r = l = p = lp = 0
for c in input():
    if c != p:
        if c == '<':
            r -= min(l, lp)
        p = c
        lp = l
        l = 0
    l += 1
    r += l
if p == '>':
    r -= min(l, lp)   
print(r)


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

ans = 0

cnt0 = 0
if S[0] == ">":
    cnt0 += 1
    j = 1
    while j <= len(S)-1 and S[j] == ">":
        cnt0 += 1
        j += 1
ans += cnt0*(cnt0+1)//2
print(cnt0)

for i in range(1, N-1):
    if S[i-1] == "<" and S[i] == ">":
        j = i-1
        k = i+1
        cnt1 = 0
        cnt2 = 0
        if S[i-1] == "<" and i >= 0:
            while j >= 0 and S[j] == S[i-1] :
                cnt1 += 1 
                j -= 1
        if S[i] == ">":
            while k <= N-1 and S[i] == S[k-1]:
                cnt2 += 1
                k += 1 
        ans += max(cnt1, cnt2)*(max(cnt1, cnt2)+1)//2
        ans += (min(cnt1, cnt2)-1)*(min(cnt1, cnt2))//2
        print(cnt1, cnt2)

cntn = 0
if S[-1] == "<":
    cntn += 1
    j = -2
    while j >= -len(S) and S[j] == "<":
        cntn += 1
        j -= 1
ans += cntn*(cntn+1)//2
print(cntn)

print(ans)

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

ans = 0

cnt0 = 0
if S[0] == ">":
    cnt0 += 1
    j = 1
    while j <= len(S)-1 and S[j] == ">":
        cnt0 += 1
        j += 1
ans += cnt0*(cnt0+1)//2


for i in range(1, N-1):
    if S[i-1] == "<" and S[i] == ">":
        j = i-1
        k = i+1
        cnt1 = 0
        cnt2 = 0
        if S[i-1] == "<" and i >= 0:
            while j >= 0 and S[j] == S[i-1] :
                cnt1 += 1 
                j -= 1
        if S[i] == ">":
            while k <= N-1 and S[i] == S[k-1]:
                cnt2 += 1
                k += 1 
        ans += max(cnt1, cnt2)*(max(cnt1, cnt2)+1)//2
        ans += (min(cnt1, cnt2)-1)*(min(cnt1, cnt2))//2


cntn = 0
if S[-1] == "<":
    cntn += 1
    j = -2
    while j >= -len(S) and S[j] == "<":
        cntn += 1
        j -= 1
ans += cntn*(cntn+1)//2


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):
import sys
from operator import itemgetter
input = sys.stdin.readline

_s = input()


def chker(s):
    i = 1
    minisum = 0
    while len(s) >= i:
        if s[i - 1:i + 1] == '><':
            item = s[:i]
            l = item.count('<')
            r = len(item) - l
            l, r = (l, r) if l > r else (r, l)
            minisum += l * (l + 1) / 2 + r * (r - 1) / 2

            s = s[i:]
            i = 1
        else:
            i += 1

    item = s
    l = item.count('<')
    r = len(item) - l
    l, r = (l, r) if l > r else (r, l)
    minisum += l * (l + 1) / 2 + r * (r - 1) / 2

    print(int(minisum))


chker(_s)


import sys
from operator import itemgetter
input = sys.stdin.readline

_s = input()


def chker(s):
    l, r, minisum = 0, 0, 0
    if s[0] == '<':
        l += 1
    elif s[0] == '>':
        r += 1
    for i in range(1, len(s)):
        if s[i - 1] == '>' and s[i] == '<':
            l, r = (l, r) if l > r else (r, l)
            minisum += l * (l + 1) / 2 + r * (r - 1) / 2
            l, r = 1, 0
        else:
            if s[i] == '<':
                l += 1
            elif s[i] == '>':
                r += 1

    l, r = (l, r) if l > r else (r, l)
    minisum += l * (l + 1) / 2 + r * (r - 1) / 2

    print(int(minisum))


chker(_s)


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


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))
if s[0] == "<":
    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]
else:
    result += ls[0]
    ls = ls[1:]
    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))


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))
if s[0] == "<":
    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]
else:
    result += ls[0]
    ls = ls[1:]
    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))


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 collections

s = list(input())
s_count = collections.Counter(s)
max_s = min(s_count[">"], s_count["<"])
ans = sum(range(1, max_s + 1))
print(ans)


import collections

s = list(input())
s_count = collections.Counter(s)
max_s = min(s_count[">"], s_count["<"])
ans = sum(range(1, max_s + 1))
print(ans)


S = list(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: 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()
l = [s[0]]
for c in s[1:]:
    if c in l[-1]:
        l[-1] += c
    else:
        l.append(c)
a = []
now = 0
for c in l:
    if '<' in c:
        if now == 0:

            for i in range(len(c) + 1):
                a.append(i)
        else:
            for i in range(1, len(c) + 1):
                a.append(i)
        now = len(c)
    if '>' in c:
        if now <= len(c):
            if now != 0:
                a.pop()
            for i in reversed(range(len(c) + 1)):
                a.append(i)
        else:
            for i in reversed(range(len(c))):
                a.append(i)
        now = len(c) + 1
print((a))

def sigma(n):
    return n * (n + 1) // 2

s = list(map(lambda x : 1 if x == '<' else -1, input()))
l = [s[0]]
for c in s[1:]:
    if c * l[-1] > 0:
        l[-1] += c
    else:
        l.append(c)
ans = 0
now = 0
for c in l:
    if c < 0:
        ans -= min(now, abs(c))
    ans += sigma(abs(c))
    now = abs(c)
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
L = []
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]))

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

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

S = input()

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

for n in range(N-2):
    counter += 1
    if S[n]!=S[n+1]:
        L.append(counter)
        counter = 0
            
L.append(counter+1)

if S[0]=='<':
    K = len(L)//2
    for k in range(K):
        if L[2*k] <= L[2*k+1]:
            L[2*k] -= 1
        else:
            L[2*k+1] -= 1

else:
    K = (len(L)-1)//2
    for k in range(K):
        if L[2*k+1] <= L[2*k+2]:
            L[2*k+1] -= 1
        else:
            L[2*k+2] -= 1
        
print(sum([l*(l+1)//2 for l in L]))

Verdicts: Runtime Error

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()
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)-2, -1, -1):
    if s[i] == '>':
        a[i] = max(a[i], a[i+1]+1)

print(sum(a))


s = list(input())
al = [0]*(len(s)+1)

for i in range(len(s)):
    if s[i] == '<':
        al[i+1] = max(al[i]+1, al[i+1])

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

print(sum(al))

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):
#!/usr/bin/env python3
import sys

def count_L(S, N):
    ret=0
    for i in range(N):
        if S[i:i+1]=='>':
            ret+=1
        else:
            break
    return ret

def solve(S: str):
    a=[0]*(len(S))

    for i in range(len(S)-1):
        if S[i:i+1]=='<':
            if S[i+1:i+2]=='>': #a[i-1] < a[i] > a[i+1]
                a[i]=max(a[i-1]+1,count_L(S[i+1:],len(S[i+1:])))
            else:               #a[i-1] < a[i] < a[i+1]
                a[i]=a[i-1]+1
        else:
            if S[i+1:i+2]=='>': #a[i-1] > a[i] > a[i+1]
                a[i]=count_L(S[i+1:],len(S[i+1:]))
            else:               #a[i-1] > a[i] < a[i+1]
                a[i]=0
    if S[-1:]=='<':
        a[len(S)-1]=a[len(S)-2]+1

    print(a,sum(a))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

#!/usr/bin/env python3
import sys

#count '<'
def count_S(S, N):
    ret=S.find('>')
    #print("<",S,N,ret)
    if ret==-1:
        ret=N
    return ret

#count '>'
def count_L(S, N):
    ret=S.find('<')
    if ret==-1:
        ret=N
    #print(">",S,N,ret)
    return ret

def count_S_slow(S, ns, N):
    ret=0
    for i in range(ns,N):
        if S[i:i+1]=='<':
            ret+=1
        else:
            break
    return ret

def count_L_slow(S, ns, N):
    ret=0
    for i in range(ns,N):
        if S[i:i+1]=='>':
            ret+=1
        else:
            break
    return ret

def solve(S: str):
    answer=0
    
    numS=len(S)
    cnt_l=count_L(S,len(S))
    answer+=(cnt_l+1)*cnt_l//2
    i=cnt_l
    while i<len(S):
        cnt_s=count_S_slow(S,i,numS)
        cnt_l=count_L_slow(S,i+cnt_s,numS)
        answer+=(cnt_s+1)*cnt_s//2
        answer+=(cnt_l+1)*cnt_l//2
        if cnt_l>cnt_s:
           answer-=cnt_s
        else:
           answer-=cnt_l
        #answer+=(cnt_l+1)*cnt_l//2
        #print("cnt_s,cnt_l",cnt_s, cnt_l,answer)
        i+=cnt_s+cnt_l

    print(answer)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

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


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<

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()
l=len(s)
a=[0 for i in range(l+1)]
for i in range(l):
    if s[i]=='<':
        a[i+1]=max(a[i+1],a[i]+1)
        print(a)
for i in range(l-1,-1,-1):
    if s[i]=='>':
        a[i]=max(a[i+1]+1,a[i])
        print(a)
print(sum(a))

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

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):
print(s)
n=len(s)

c=0
N=0
j=0
k=0
for i in range(1,n):
  if (s[i-1]=="<" and s[i]==">"):
    #print(i)
    j=i
    N+=math.factorial(i-k)
    #print("<>",i-k)
  if (s[i-1]==">" and s[i]=="<"):
    k=i
    N+=math.factorial(i-j)
    #print("><",i-j)
print(N)

s=input()+"1"
a=0
b=[]
i=0
l=len(s)
e=0
while True:
    if s[i]==s[i+1]:
        a+=1
    else:
        b.append(a+1)
        a=0
    i+=1
    if i+1>=l:
        break
if s[-2]=='<':
    b.append(0)
if s[0]=='>':
    b.insert(0,0)
for i in range(len(b)//2):
    c,d=max(b[i*2],b[i*2+1]),min(b[i*2],b[i*2+1])
    e+=(c*(c+1)//2)+(d*(d-1)//2)
print(e)

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

S = input()
#print(len(S))

if len(S) == 1:
    print("1")
    exit()

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
s_list[len(s_list)-1] = 0 if s_list[len(s_list)-1] < 0 else s_list[len(s_list)-1] 
#print(s_list)
for i in range(len(S)-1,0,-1):
    if S[i] == ">" and S[i-1] == ">":
    #if S[i] == ">":
        s_list[i] = count
        count += 1
    elif S[i] == ">" and S[i-1] == "<":
        s_list[i] = max(s_list[i-1], s_list[i+1]) + 1
    else:
        count = 1

if S[0] == ">":
    s_list[0] = s_list[1] + 1
if S[len(S)-1] == ">":
    s_list[len(s_list)-1] =  0

#print(len(s_list))
#print(s_list)

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

print(sum)
    

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 = list(s)
a = 1
result = 0
first_s = l[0]
tmp_s = first_s
count = 0
conseq = []
for item in l:
    if item == tmp_s:
        count += 1
    else:
        conseq.append(count)
        count = 1
        tmp_s = item
conseq.append(count)

def my_sum(n, m):
    if n == m:
        return n
    else:
        tmp = 0
        for i in range(n, m+1):
            tmp += i
        return tmp

if first_s == '>':
    result = conseq[0]
tmp_s = first_s
for i in range(len(conseq)):
    print(result)
    print(conseq[i], tmp_s)
    if i+1 == len(conseq):
        if tmp_s =='<':
            result += my_sum(0, conseq[i])
        else:
            result += my_sum(0, conseq[i]-1)
        break
    if tmp_s == '<':
        if conseq[i] >= conseq[i+1]:
            result += my_sum(0, conseq[i])
        else:
            result += my_sum(0, conseq[i])
            result += conseq[i+1]-conseq[i]
        tmp_s = '>'
    else:
        result += my_sum(0,conseq[i]-1)
        #result += conseq[i+1]-conseq[i]
        tmp_s = '<'
print(result)

s = str(input())
l = list(s)
a = 1
result = 0
first_s = l[0]
tmp_s = first_s
count = 0
conseq = []
for item in l:
    if item == tmp_s:
        count += 1
    else:
        conseq.append(count)
        count = 1
        tmp_s = item
conseq.append(count)

def my_sum(n, m):
    if n == m:
        return n
    else:
        tmp = 0
        for i in range(n, m+1):
            tmp += i
        return tmp

if first_s == '>':
    result = conseq[0]
tmp_s = first_s
for i in range(len(conseq)):
    if i+1 == len(conseq):
        if tmp_s =='<':
            result += my_sum(0, conseq[i])
        else:
            result += my_sum(0, conseq[i]-1)
        break
    if tmp_s == '<':
        if conseq[i] >= conseq[i+1]:
            result += my_sum(0, conseq[i])
        else:
            result += my_sum(0, conseq[i])
            result += conseq[i+1]-conseq[i]
        tmp_s = '>'
    else:
        result += my_sum(0,conseq[i]-1)
        tmp_s = '<'
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):
def calc(n):
    return n * (n+1) / 2

S = list(input())

prev = S[0]
series = 1
l = []

for i in range(1, len(S)):
    if prev == S[i]:
        series += 1
    else:
        l.append((prev, series))
        prev = S[i]
        series = 1

l.append((prev, series))

prev_max = l[0][1]
prev = calc(prev_max)
res = prev

print(l)

for s, n in l[1::]:
    if s == '<':
        prev = calc(n)
        prev_max = n
        res += prev
    else:
        if n >= prev_max:
            res -= prev_max
            prev = calc(n)
            res += prev
        else:
            prev = calc(n-1)
            res += prev

    print(res)

print(int(res))


import math

S = list(input())

prev = S[0]
series = 1
l = []

for i in range(1, len(S)):
    if prev == S[i]:
        series += 1
    else:
        l.append((prev, series))
        series = 1


prev_max = l[0][1]-1
prev = math.factorial(l[0][1]-1)
res = prev

for s, n in range(len(l)):
    if s == '<':
        prev = math.factorial(n-1)
        prev_max = n-1
        res += prev
    else:
        if n-1 > prev_max:
            prev = math.factorial(n-2)
            res += prev
        else:
            res -= prev_max
            prev = math.factorial(n-1)
            res += prev

print(res)


def calc(n):
    return n * (n+1) / 2

S = list(input())

prev = S[0]
series = 1
l = []

for i in range(1, len(S)):
    if prev == S[i]:
        series += 1
    else:
        l.append((prev, series))
        prev = S[i]
        series = 1

l.append((prev, series))

prev_max = l[0][1]
prev = calc(prev_max)
res = prev

for s, n in l[1::]:
    if s == '<':
        prev = calc(n)
        prev_max = n
        res += prev
    else:
        if n >= prev_max:
            res -= prev_max
            prev = calc(n)
            res += prev
        else:
            prev = calc(n-1)
            res += prev

print(int(res))


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

def main():
    S = list(input())
    lenS = len(S)
    bfr = -1
    cnt = 0
    ans = []
    dwn = 0
    S.append('<')
    while cnt <= lenS:
        nxt = S[cnt]
        if nxt == '<' and dwn == 0:
            ans.append(max(0,bfr+1))
            bfr = max(0, bfr+1)
            cnt += 1
        elif nxt == '<' and dwn > 0:
            ans.append(max(bfr+1, dwn))
            ans += range(dwn-1, -1, -1)
            bfr = 0
            cnt += 1
            dwn = 0
        else:
            dwn += 1
            cnt += 1
    print(ans)
    print(sum(ans))

if __name__ == "__main__":
    main()



def main():
    S = list(input())
    lenS = len(S)
    bfr = -1
    cnt = 0
    ans = []
    dwn = 0
    S.append('<')
    while cnt <= lenS:
        nxt = S[cnt]
        if nxt == '<' and dwn == 0:
            ans.append(max(0,bfr+1))
            bfr = max(0, bfr+1)
            cnt += 1
        elif nxt == '<' and dwn > 0:
            ans.append(max(bfr+1, dwn))
            ans += range(dwn-1, -1, -1)
            bfr = 0
            cnt += 1
            dwn = 0
        else:
            dwn += 1
            cnt += 1
    #print(ans)
    print(sum(ans))

if __name__ == "__main__":
    main()


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):
def main():
  import sys
  input = sys.stdin.readline

  f = "" 
  ans = 0 # Answer
  count = 0 # Ai
  continuous = 0 
  
  for m in str(input()):
    if m=="<":
      if f==">" and count>0:
        
        ans-=count*continuous
        count=0
      count+=1
        
    else:
      if f=="<":
        
        continuous=0
      count-=1
      continuous+=1
      if count==-1:
        ans+=continuous
        count=0
        continue

    ans+=count
    f=m

  print(ans)
    
if __name__ == '__main__':
    main()

s=list(input())
f=s[0]
now=0
suc=0
ans=0
for o in s:
  if f=="<" and o=="<":
    now+=1
    ans+=now
    #print(o,now,ans)
  if f=="<" and o==">":
    suc=1
    now+=1
    ans+=now
    #print(o,now,ans)
  if f==">" and o=="<":
    now-=1
    if now>=0:
      ans-=(suc-1)*now
      now=0
    else:
      ans+=suc
      now=0
    suc=0
    #print(o,now,ans)
  if f==">" and o==">":
    now-=1
    if now==-1:
      ans+=suc
      now=0
    else:
      ans+=now
    suc+=1
  print(o,suc)
  f=o

print(ans)

def main():
  import sys
  input = sys.stdin.readline

  f = "" 
  ans = 0 # Answer
  count = 0 # Ai
  continuous = 0 
  
  for m in input():
    if m=="<":
      if f==">" and count>0:
        
        ans-=count*continuous
        count=0
      count+=1
        
    else:
      if f=="<":
        
        continuous=0
      count-=1
      continuous+=1
      if count==-1:
        ans+=continuous
        count=0
        continue

    ans+=count
    f=m

  print(ans)
    
if __name__ == '__main__':
    main()

from itertools import groupby
s=list(input())
f=0
ans=0
for k,v in groupby(s):
  d=len(list(v))
  g=d+1 if k==">" else 0 
  ans+=( max(f,g)-min(f,g)+d*(d+1)//2-g )
  f=d+1 if k=="<" else 0
print(ans)  

def main():
  import sys

  f = "" 
  ans = 0 # Answer
  count = 0 # Ai
  continuous = 0 
  
  for m in sys.stdin.readline().strip("\n"):
    if m=="<":
      if f==">" and count>0:
        
        ans-=count*continuous
        count=0
      count+=1
        
    else:
      if f=="<":
        
        continuous=0
      count-=1
      continuous+=1
      if count==-1:
        ans+=continuous
        count=0
        continue

    ans+=count
    f=m

  print(ans)
    
if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

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 = input()
len_s = len(s)
ans_array = [0 for x in range(len_s+1)]
for index in range(len_s):
    if s[index] == "<":
        ans_array[index + 1] = ans_array[index]+1
print(ans_array)
for index in reversed(range(len_s)):
    if s[index] == ">":
        ans_array[index] = max(ans_array[index+1]+1, ans_array[index])
print(sum(ans_array))

s = input()
len_s = len(s)
ans_array = [0 for x in range(len_s+1)]
for index in range(len_s):
    if s[index] == "<":
        ans_array[index + 1] = ans_array[index]+1
for index in reversed(range(len_s)):
    if s[index] == ">":
        ans_array[index] = max(ans_array[index+1]+1, ans_array[index])
print(sum(ans_array))

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
l=[0]*n
r=[0]*n
for i in range(n-1):
    if S[i]=='<': 
      l[i+1]=l[i]+1
    if S[n-2-i]=='>': 
      r[n-2-i]=r[n-1-i]+1
ans=0
for i in range(N):
  ans+=max(l[i],r[i])
print(ans)


s=input()
n=len(s)+1
l=[0]*n
r=[0]*n
for i in range(n-1):
    if s[i]=='<': 
      l[i+1]=l[i]+1
    if s[n-2-i]=='>': 
      r[n-2-i]=r[n-1-i]+1
ans=0
for i in range(n):
  ans+=max(l[i],r[i])
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()

s = S.replace('<>', '<,>').replace('><', '>,<').split(',')
lst1 = [ss.count('<') - ss.count('>') for ss in s]

ans = [0]

for i in lst:
    if i > 0:
        ans += list(range(1,i+1))
    else:
        ans[-1] = max(ans[-1], -i)
        ans += list(range(-i-1,-1, -1))

print(sum(ans))

S = input()

s = S.replace('<>', '<,>').replace('><', '>,<').split(',')
lst = [ss.count('<') - ss.count('>') for ss in s]

ans = [0]

for i in lst:
    if i > 0:
        ans += list(range(1,i+1))
    else:
        ans[-1] = max(ans[-1], -i)
        ans += list(range(-i-1,-1, -1))

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

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

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

S = ('<' if S[0] == '>' else '>') + S \
    + ('<' if S[-1] == '>' else '>') 
print(S)
for i in range(n):
    if S[i : i + 2] == '><': 
        for j in range(i, 0, -1):   
            if S[j] == '<': break
            a[j - 1] = max(a[j - 1], a[j] + 1)
        for j in range(i + 1, n):   
            if S[j] == '>': break
            a[j] = max(a[j], a[j - 1] + 1)

print(sum(a))

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

S = ('<' if S[0] == '>' else '>') + S \
    + ('<' if S[-1] == '>' else '>') 
    
for i in range(n):
    if S[i : i + 2] == '><': 
        for j in range(i, 0, -1):   
            if S[j] == '<': break
            a[j - 1] = max(a[j - 1], a[j] + 1)
        for j in range(i + 1, n):   
            if S[j] == '>': break
            a[j] = max(a[j], a[j - 1] + 1)

print(sum(a))

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

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)-2,0,-1):
    if S[i]=='>':
        A[i]=max(A[i],A[i+1]+1)

print(sum(A))


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

l = [for i in range(len(s) + 1)]

for x in range(len(s)-1):
    for y in range(len(s)-1-x):
        if '<' == s[y] and l[y] > l[y+1]:
            l[y], l[y+1] = l[y+1], l[y]

        elif '<' == s[y] and l[y] < l[y+1]:
            l[y], l[y+1] = l[y], l[y+1]

        elif '>' == s[y] and l[y] > l[y+1]:
            l[y], l[y+1] = l[y], l[y+1]

        elif '>' == s[y] and l[y] < l[y+1]:
            l[y], l[y+1] = l[y+1], l[y]

print(sum(l))


def inc(a, b, inc_a, a_max, b_max, n, n_max):
    cnt = 0
    n += 1

    if inc_a:
        a += 1
    else:
        b += 1

    if a == a_max and b == b_max and n == n_max:
        return 1

    if a > b or a > a_max or b > b_max or n > n_max:
        return 0

    cnt += inc(a, b, True, a_max, b_max, n, n_max)
    cnt += inc(a, b, False, a_max, b_max, n, n_max)
    cnt += same(a, b, a_max, b_max, n, n_max)
    return cnt


def same(a, b, a_max, b_max, n, n_max):
    if b - a == 1:
        return 0

    cnt = 0
    n += 1

    a = b

    if a == a_max and b == b_max and n == n_max:
        return 1

    if a > b or a > a_max or b > b_max or n > n_max:
        return 0

    cnt += inc(a, b, True, a_max, b_max, n, n_max)
    cnt += inc(a, b, False, a_max, b_max, n, n_max)
    cnt += same(a, b, a_max, b_max, n, n_max)
    return cnt


if __name__ == '__main__':
    n_max, a_max, b_max = list(map(int, input().split()))
    n = 0
    a = 0
    b = 0
    cnt = 0

    cnt += inc(a, b, False, a_max, b_max, n, n_max)
    cnt += same(a, b, a_max, b_max, n, n_max)
    print(cnt)


S=input()
N=len(S)+1
S='>'+S+'<'
a=[0] * (N+2)

i=1
while i<=N:
    if S[i-1]==">" and S[i]=="<":
        a[i]=0

        j=i
        while j>=1:
            if S[j-1]==">":
                if a[j-1]<=a[j]:
                    a[j-1]=a[j]+1
                j=j-1
            else:
                break

        k=i
        while k<=N:
            if S[k]=="<":
                if a[k+1]<=a[k]:
                    a[k+1]=a[k]+1
                k=k+1
            else:
                break
    i=i+1

a[0]=0
a[N+1]=0
print(sum(a))


Verdicts: Runtime Error

Runtime Error

Accepted