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):
s = input()
comp = []

cur = s[0]
streak = 0
count = 0

for i in range(len(s)):
    if s[i] == cur:
        streak += 1
    else:
        if (len(comp) == 0):
            if cur == ">":
                count += streak*(streak+1)//2
        else:
            if cur == ">":
                prevStreak = comp[-1][1]
                count += (prevStreak*(prevStreak+1) + streak*(streak+1)) // 2
                count -= min(streak, prevStreak)

        comp.append((cur, streak))
        streak = 1
        cur = s[i]

    if i == (len(s) - 1):
        if (len(comp) == 0):
            if cur == ">":
                count += streak*(streak+1)//2

        if cur == "<":
            count += streak*(streak+1)//2

print(count)

s = input() + "."
comp = []

cur = s[0]
streak = 0
count = 0

for i in range(len(s)):
    if s[i] == cur:
        streak += 1
    else:
        if (len(comp) == 0):
            if cur == ">":
                count += streak*(streak+1)//2
            elif i == (len(s) - 1):
                count += streak*(streak+1)//2
        elif cur == ">":
            prevStreak = comp[-1][1]
            count += (prevStreak*(prevStreak+1) + streak*(streak+1)) // 2
            count -= min(streak, prevStreak)
        elif i == (len(s) - 1):
            if cur == "<":
                count += streak*(streak+1)//2

        comp.append((cur, streak))
        streak = 1
        cur = s[i]

print(count)

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):
i=0
while i<len(s):
  k=0
  while s[i]=='<' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
  k=0
  while s[i]=='>' if i<len(s) else False:
    k+=1
    i+=1
sm=0
for i in l:
  sm+=(i*(i+1))//2
  
print(sm)

s=input()
l=[]
i=0
while i<len(s):
  k=0
  while s[i]=='<' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
  k=0
  while s[i]=='>' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
sm=0
for i in l:
  sm+=(i*(i+1))//2
for i in range(0 if s[0]=='<' else 1,len(l)-1,2):
  sm-=min(l[i],l[i+1])
 
  
print(sm)

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())
zeroone = []
for i in range(len(S)):
    if S[i] == "<":
        zeroone.append(1)
    else:
        zeroone.append(-1)

cnt = [0]
for i in range(len(zeroone)-1):
    if zeroone[i+1] != zeroone[i]:
        cnt.append(i+1)
cnt.append(len(zeroone))

ans = [0] * (len(zeroone)+1)
for i in range(len(zeroone)-1):
    if zeroone[i+1] - zeroone[i] > 0:
        for j in range(i+1, cnt[cnt.index(i+1) + 1]):
            ans[j+1] = ans[j] + 1

        for k in range(cnt[cnt.index(i+1) - 1], i+1)[::-1]:
            ans[k] = max(ans[k+1] + 1, ans[k])

print(sum(ans))

# coding: utf-8

S = list(input())
S.append("end")

def count(r, l):
    part_sum = ((r-1)*r + (l-1)*l)/2 
    part_max = max(r, l) 
    return(part_sum + part_max)

ans = 0
r = l = 0
for i in range(len(S)-1):
    if S[i+1] != S[i] and S[i] == ">": 
        r += 1
        ans += count(r, l)
        r = l = 0
    elif S[i] == "<":
        l += 1
    elif S[i] == ">":
        r += 1
ans += count(r, l) 
print(int(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()
a = [-1 for i in range(len(s)+1)]
for i in range(len(s)-1):
    if s[i] == '>' and s[i+1] == "<":
        a[i+1] = 0
if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
def plus(i):
    j = i - 1
    while s[j] == '>':
        a[j] = max(a[j+1] + 1, a[j])
        j -= 1
        if j < 0:
            break
    j = i
    while s[j] == '<':
        a[j+1] = max(a[j] + 1, a[j+1])
        j += 1
        if  j == len(a) - 1:
            break
for i in range(len(a)):
    if a[i] == 0:
        plus(i)
print(sum(a))


s = input()
a = [-1 for i in range(len(s)+1)]
for i in range(len(s)-1):
    if s[i] == '>' and s[i+1] == "<":
        a[i+1] = 0
if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
def plus(i):
    j = i -1
    while j >= 0 and s[j] == '>':
        a[j] = max(a[j+1] + 1, a[j])
        j -= 1
    j = i
    if j == len(a) -1:
        return
    while s[j] == '<':
        a[j+1] = max(a[j] + 1, a[j+1])
        j += 1
        if  j == len(a) - 1:
            break
for i in range(len(a)):
    if a[i] == 0:
        plus(i)
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):
S = list(input())
len_S = len(S)
a = [0]*(len_S+1)
for i, s in enumerate(S):
    if s == '<':
        a[i+1] = a[i]+1
for i, s in enumerate(S[::-1]):
    inv_i = len_S-1-i
    if s == '>':
        a[inv_i] = max(a[inv_i+1]+1, a[inv_i])
print(a)


S = list(input())
len_S = len(S)
a = [0]*(len_S+1)
for i, s in enumerate(S):
    if s == '<':
        a[i+1] = a[i]+1
for i, s in enumerate(S[::-1]):
    inv_i = len_S-1-i
    if s == '>':
        a[inv_i] = max(a[inv_i+1]+1, a[inv_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)


prev = ""
for i in range(len(S)):
    print(S[i])
    if S[i] == "<":
        ans[i + 1] = ans[i] + 1
        prev = "<"

    print(ans)
ans.reverse()
print()
for i in range(len(S)):
    print(S[len(S)-1-i])
    if S[len(S)-1-i] == ">" and (ans[i+1] == 0 or ans[i+1] == 1):
        ans[i + 1] = ans[i] + 1
        prev = ">"
    print(ans)
print()
print(sum(ans))

S = input()

ans = [0] * (len(S) + 1)


prev = ""
for i in range(len(S)):
    # print(S[i])
    if S[i] == "<":
        ans[i + 1] = ans[i] + 1
        prev = "<"

    # print(ans)
ans.reverse()
print()
for i in range(len(S)):
    # if S[len(S) - 1 - i] == ">":
    #     print("<")
    # else:
    #     print(">")
    # print(S[len(S)-1-i])
    if S[len(S)-1-i] == ">" and (ans[i+1] == 0 or ans[i+1] == 1):
        ans[i + 1] = ans[i] + 1
        prev = ">"
    # print(ans)
# print()
print(sum(ans))


S = input()

ans = [0] * (len(S) + 1)


prev = ""
for i in range(len(S)):
    # print(S[i])
    if S[i] == "<":
        ans[i + 1] = ans[i] + 1
        prev = "<"

    # print(ans)
ans.reverse()
for i in range(len(S)):
    # if S[len(S) - 1 - i] == ">":
    #     print("<")
    # else:
    #     print(">")
    if S[len(S)-1-i] == ">" and not ans[i] < ans[i+1]:
        ans[i + 1] = ans[i] + 1
        prev = ">"
    # print(ans)
# print()
print(sum(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()
big = 0
small = 0
n = 0
big2 =0
for i in range(len(s)):
  if s[i]=='<':
    big += 1
    n += big
    small =0
    big2 = big
  else:
    small += 1
    n += small
    if small<=big2:
      n-=1
      big =0
  print(n)

s = input()
big = 0
small = 0
n = 0
big2 =0
for i in range(len(s)):
  if s[i]=='<':
    big += 1
    n += big
    small =0
    big2 = big
  else:
    small += 1
    n += small
    if small<=big2:
      n-=1
      big =0
print(n)

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)
dp = [0]*(n+1)
t = 0
for e,i in enumerate(s,1):
    if i=='<' :
        dp[e]=dp[e-1]+1
print(dp)
t = 0
for e in range(n-1,-1,-1):
    i = s[e]
    print(t)
    if i=='>' :
        dp[e]=max(dp[e],dp[e+1]+1)
# print(dp)
print(sum(dp))

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

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

tmp_list = [0]
bigger = True
for i in range(len(S)):
    if (bigger and S[i] == '<') or (not bigger and S[i] == '>'):
        tmp_list[-1] += 1
    else:
        tmp_list.append(1)
        bigger = not bigger
print(tmp_list)

if len(tmp_list) % 2 == 1:
    tmp_list.append(0)

def func(x):
    return x * (x + 1) // 2

ans = 0
for i in range(len(tmp_list) // 2):
    a = tmp_list[i * 2]
    b = tmp_list[i * 2 + 1]
    if a > b:
        a, b = b, a
    ans += func(a - 1)
    ans += func(b)

print(ans)

S = str(input())

tmp_list = [0]
bigger = True
for i in range(len(S)):
    if (bigger and S[i] == '<') or (not bigger and S[i] == '>'):
        tmp_list[-1] += 1
    else:
        tmp_list.append(1)
        bigger = not bigger

if len(tmp_list) % 2 == 1:
    tmp_list.append(0)

def func(x):
    return x * (x + 1) // 2

ans = 0
for i in range(len(tmp_list) // 2):
    a = tmp_list[i * 2]
    b = tmp_list[i * 2 + 1]
    if a > b:
        a, b = b, a
    ans += func(a - 1)
    ans += func(b)

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()
print(s.count("<"))
print(s.count(">"))
print(len(s))
a=[0]*len(s)
for i in range(len(s)+1):
    if s[i]=="<":
        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))

s=input()
a=[0]*len(s)
for i in range(len(s)+1):
    if s[i]=="<":
        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))

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

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):
# coding: utf-8
# Your code here!
S=list(input())

nums=[1 if S[0]=="<" else -1]
for i in range(len(S)-1):
    if S[i+1]==S[i]:
        if S[i+1]=="<":
            nums[-1]+=1
        else:
            nums[-1]-=1
    else:
        if S[i+1]=="<":
            nums.append(1)
        else:
            nums.append(-1)

ans=0
if nums[0]<0:
    are=nums.pop(0)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()
if nums[-1]>0:
    are=nums.pop(-1)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()

temp=list(map(lambda x:abs(x)-1,nums))
temp=list(map(lambda x:x*(x+1)//2,temp))

ans+=sum(temp)
#print(ans)
for i in range(len(nums)-1):
    if nums[i]>0:
        ans+=max(nums[i],-nums[i+1])
print(nums)
print(ans)


# coding: utf-8
# Your code here!
S=list(input())

nums=[1 if S[0]=="<" else -1]
for i in range(len(S)-1):
    if S[i+1]==S[i]:
        if S[i+1]=="<":
            nums[-1]+=1
        else:
            nums[-1]-=1
    else:
        if S[i+1]=="<":
            nums.append(1)
        else:
            nums.append(-1)

ans=0
if nums[0]<0:
    are=-nums.pop(0)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()
if nums[-1]>0:
    are=nums.pop(-1)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()

temp=list(map(lambda x:abs(x)-1,nums))
temp=list(map(lambda x:x*(x+1)//2,temp))

print(temp)
ans+=sum(temp)
#print(ans)
for i in range(len(nums)-1):
    if nums[i]>0:
        ans+=max(nums[i],-nums[i+1])

print(ans)


# coding: utf-8
# Your code here!
S=list(input())

nums=[1 if S[0]=="<" else -1]
for i in range(len(S)-1):
    if S[i+1]==S[i]:
        if S[i+1]=="<":
            nums[-1]+=1
        else:
            nums[-1]-=1
    else:
        if S[i+1]=="<":
            nums.append(1)
        else:
            nums.append(-1)

ans=0
if nums[0]<0:
    are=-nums.pop(0)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()
if nums[-1]>0:
    are=nums.pop(-1)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()

temp=list(map(lambda x:abs(x)-1,nums))
temp=list(map(lambda x:x*(x+1)//2,temp))

#print(temp)
ans+=sum(temp)
#print(ans)
for i in range(len(nums)-1):
    if nums[i]>0:
        ans+=max(nums[i],-nums[i+1])

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()
n=len(s)
ans=[]
count=0
t= [0]*(n+1)
for i in range(n):
  if s[i]=="<":
    s[i+1]=s[i]+1
  else:
    s[i+1]=0
count=0
for i in range(n-1,-1,-1):
  if s[i]==">":
    s[i-1]=max(s[i]+1,s[i-1])
print(sum(ans))
  
  

import collections
S = input()

s = list(S.split("><"))
ans = 0
for i in range(len(s)):
    table = collections.defaultdict(int)
    for y in s[i]:
        table[y] += 1

    if i == 0 and len(table) != 0:
        table["<"] -= 1
    if i == len(s)-1 and len(table) != 0:
        table[">"] -= 1
    table = list(table.values())
    if len(table) == 2:
        table.sort()
        ans += max((table[1]+1)*(table[1]+2) // 2, 0)
        ans += max((table[0]+1)*table[0] // 2, 0)

    elif len(table) == 1:
        ans += max((table[0]+1)*(table[0]+2) // 2, 0)
    else:
        ans += 1
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()
n = len(s)
a = [0]*(n+1)
hidari = [0] *(n+1)
for i in range(1,n+1):
    if s[i-1] == '<':
        res +=1
    else:res = 0
    hidari[i] = res
hidari[-1] = res
res = 0
migi = [0] *(n+1)
for i in range(n-1,-1,-1):
    if s[i] == '>':
        res+=1
    else:res = 0
    migi[i] = res
migi[0] = res
ans = 0
for i in range(n+1):
    ans += max(migi[i],hidari[i])
print(ans)

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

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

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):
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
LR = [tuple(map(int, input().split())) for _ in range(n)]

def quicksort(x):
    if x==[]: return []

    smallerSorted = quicksort([a for a in x[1:] if a[0] < x[0][0] or (a[0] == x[0][0] and a[1] => x[0][1])])
    biggerSorted = quicksort([a for a in x[1:] if a[0] > x[0][0] or (a[0] == x[0][0] and a[1] < x[0][1])])

    return(smallerSorted+[x[0]]+biggerSorted)

LR = quicksort(LR)

ans = [0] * (n+1)
temp = 10 ** 9
i = 1
for L, R in LR:
    temp = min(temp, R)
    if L > temp:
        break   
    ans[i] = temp - L + 1
    i += 1

temp = 10 ** 9
i = n - 1
L = LR[-1][0]
for x, R in reversed(LR):
    temp = min(temp, R)
    if L > temp:
        break
    ans[i] += temp - L + 1
    i -= 1

res = max(ans)
for L, R in LR:
    res = max(res, R - L + 1)

print(res)

S = list(input())

n = len(S) + 1

a = [0] * n

for i, x in enumerate(S):
    if x == '<':
        a[i+1] = a[i] + 1
    else:
        a[i+1] = 0

for i, x in enumerate(reversed(S)):
    j = n - i - 1
    if x == '>':
        a[j - 1] = max(a[j] + 1, a[j-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):
s = input()
s0 = s[0]
count = 1
nodes = []
ans = 0
for i in range(1, len(s)):
  if s0 == s[i]:
    count += 1
  elif s0 == '>':
    s0 = s[i]
    nodes.append(-count)
    count = 1
  else:
    s0 = s[i]
    nodes.append(count)
    count = 1
if s0 == '>':
  nodes.append(-count)
else:
  nodes.append(count)
print(nodes)

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

s = input()
s0 = s[0]
count = 1
nodes = []
ans = 0
for i in range(1, len(s)):
  if s0 == s[i]:
    count += 1
  elif s0 == '>':
    s0 = s[i]
    nodes.append(-count)
    count = 1
  else:
    s0 = s[i]
    nodes.append(count)
    count = 1
if s0 == '>':
  nodes.append(-count)
else:
  nodes.append(count)

for i in range(1, len(nodes)):
  if nodes[i] < 0:
    if abs(nodes[i]) > abs(nodes[i - 1]):
      nodes[i] = abs(nodes[i])
      nodes[i - 1] -= 1
    else:
      nodes[i] = abs(nodes[i])
      nodes[i] -= 1
nodes[0] = abs(nodes[0])
for i in nodes:
  ans += (i * (i + 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):
s = input().strip()
#  < > > > < < > < < < < < > > > <
# 0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1

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

buf = s[0]
count = 0
popa  = []
suma = 0
for i in s:
  if i=="<":
    count+=1
    suma += count
  elif i==">" and buf=="<":
    popa.append(count)
    suma -= count
    count = 0
  buf = i

buf = s[-1]
count = 0
dupa  = []
for i in s[::-1]:
  if i==">":
    count+=1
    suma += count
  elif i=="<" and buf==">":
    dupa.append(count)
    suma -= count
    count = 0
  buf = i
for i,j in zip(dupa,popa):
  suma+=max(i,j)
# print(sum(map(int,"0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1".split())))


s = input().strip()

buf = s[0]
count = 0
popa  = []
suma = 0
for i in s:
  if i=="<":
    count+=1
    suma += count
  elif i==">" and buf=="<":
    popa.append(count)
    suma -= count
    count = 0
  buf = i
buf = s[-1]
count = 0
dupa  = []
for i in s[::-1]:
  if i==">":
    count+=1
    suma += count
  elif i=="<" and buf==">":
    dupa.append(count)
    suma -= count
    count = 0
  buf = i

for i,j in zip(dupa[::-1],popa):
  suma+=max(i,j)
print(suma)
# print(sum(map(int,"0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1".split())))


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 = map(str, input().split())

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

S = input()

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

S = input()

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

S = input()

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

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):
#include <bits/stdc++.h>
using namespace std;


void solve(std::string S){

}

// 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)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


#!/usr/bin/env python3
import sys


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

def solve(S: str):
########################### added
    next_S = [-1 for i in range(len(S) + 1)]
    next_L = [-1 for i in range(len(S) + 1)]

    next_S[len(S)] = -1

    for i in range(len(S) - 1, -1, -1):
        if S[i] == '>':
            next_S[i] = i
        else:
            next_S[i] = next_S[i + 1]

    next_L[len(S)] = -1

    for i in range(len(S) - 1, -1, -1):
        if S[i] == '<':
            next_L[i] = i
        else:
            next_L[i] = next_L[i + 1]

###########################

    #count '<'
    def count_S(i, N):
#        ret=S.find('>')
        if i >= len(next_S):
            return N
        ret = next_S[i] - i
        if ret < 0:
            ret = N
        return ret
    
    #count '>'
    def count_L(i, N):
#        ret=S.find('<')
        if i >= len(next_L):
            return N
        ret = next_L[i] - i
        if ret < 0:
            ret = N
        return ret


#    #count '<'

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

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

    answer=0

    cnt_l=count_L(0,len(S))
    answer+=int((cnt_l+1)*cnt_l/2)
    i=cnt_l


    while i<len(S):
#        cnt_s=count_S(S[i:],len(S[i:]))
#        cnt_l=count_L(S[i+cnt_s:],len(S[i+cnt_s:]))

        cnt_s=count_S(i, len(S) - i)
        cnt_l=count_L(i+cnt_s, len(S) - (i+cnt_s))

        answer+=int((cnt_s+1)*cnt_s/2)
        answer+=int((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: 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 itertools as it
s = input()
n = len(s)
a = [0]*(n+1)
for i in range(n):
  if s[i] == "<":
    a[i+1] = +1
  if s[i] == ">":
    a[i+1] = -1
l = [0]*(n+1)
for i in range(n):
  if i < n-1:
    if s[i] == ">" and s[i+1] == "<":
      l[i+1] = 0
    else:
      l[i+1] += l[i] + a[i+1]
  else:
    l[i+1] += l[i] + a[i+1]
m = min(l)
r = [i + abs(m) for i in l]
print(sum(r))

import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    s = S()
    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: 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())
if S[-1] == '<':
  S.append('>')
else:
  S.append('<')
output = 0
count = 0
num_list = []

if S[0] == '>':
  model = 0
else:
  model = 1
s_pre = S[0]
for i in range(len(S)):
  s = S[i]
  if s != s_pre or i == len(S)-1:
    num_list.append(count)
    count = 1
    s_pre = s
  else: 
    count += 1
if model == 0:
  output += num_list[0]*(num_list[0]+1)/2
  num_list = num_list[1:]

for i in range(len(num_list)//2):
  n_max = max(num_list[2*i], num_list[2*i+1]) 
  n_min = min(num_list[2*i], num_list[2*i+1])
  print(n_max, n_min)
  output += n_max*(n_max+1)/2
  output += (n_min-1)*n_min/2
if len(num_list)%2 == 1:
  output += num_list[-1]*(num_list[-1]+1)/2
print(int(output))

S = list(input())
if S[-1] == '<':
  S.append('>')
else:
  S.append('<')
output = 0
count = 0
num_list = []

if S[0] == '>':
  model = 0
else:
  model = 1
s_pre = S[0]
for i in range(len(S)):
  s = S[i]
  if s != s_pre or i == len(S)-1:
    num_list.append(count)
    count = 1
    s_pre = s
  else: 
    count += 1
if model == 0:
  output += num_list[0]*(num_list[0]+1)/2
  num_list = num_list[1:]

for i in range(len(num_list)//2):
  n_max = max(num_list[2*i], num_list[2*i+1]) 
  n_min = min(num_list[2*i], num_list[2*i+1])
  output += n_max*(n_max+1)/2
  output += (n_min-1)*n_min/2
if len(num_list)%2 == 1:
  output += num_list[-1]*(num_list[-1]+1)/2
print(int(output))

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 = []
index = 0
diff = 0
for i in range(len(s) - 1):
    if s[i] == "<":
        a.appned(a[-1] + 1)
        index += 1

    else:
        if s[i + 1] == "<":
            diff = index - i

            if a[-1] <= diff:
                a[-1] = diff

            a = a + [diff - 1 - i for i in range(diff)]
            index += count
            count = 0
        else:
            count += 1

if count != 0:
    diff = index - len(s) + 1
    if a[-1] <= diff:
        a[-1] = diff

    a = a + [diff - 1 - i for i in range(diff)]

print(sum(a))


s = input()

index = 0
thanS = s[0]
count = 1
a = []
for i in range(1, len(s)):
    if thanS == s[i]:
        count += 1

    else:
        a.append(s[index: index + count])
        thanS = s[i]
        index = index + count
        count = 1

a.append(s[index:])
b = 0
add = 0

for i in range(len(a)):
    diff = len(a[i])
    if a[i][0] == "<":
        add += diff * (diff + 1) / 2
        b = diff
    else:
        if b < diff:
            add = add + diff * (diff + 1) / 2 - b
        else:
            add = add + (diff - 1) * diff / 2
        b = 0

print(int(add))


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()
sl=len(s)
a=[]
count=1
for i in range(sl-1):
    if s[i+1]==s[i]:
        count+=1
    else:
        a.append(count)
        count=1
a.append(count)
ans=0
al=len(a)
if s[0]=="<":
    for i in range(0,al-1,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        print(m,n)
        ans+=(m*(m+1)+n*(n-1))/2
    if al%2==1:
        ans+=a[-1]*(a[-1]+1)/2
elif s[0]==">":
    ans+=a[0]*(a[0]+1)/2
    for i in range(1,al-2,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        ans+=m*(m+1)*n*(n-1)/2
    if al%2==0:
        ans+=a[-1]*(a[-1]+1)/2
print(int(ans))

s=input()
sl=len(s)
a=[]
count=1
for i in range(sl-1):
    if s[i+1]==s[i]:
        count+=1
    else:
        a.append(count)
        count=1
a.append(count)
ans=0
al=len(a)
if s[0]=="<":
    for i in range(0,al-1,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        ans+=(m*(m+1)+n*(n-1))/2
    if al%2==1:
        ans+=a[-1]*(a[-1]+1)/2
elif s[0]==">":
    ans+=a[0]*(a[0]+1)/2
    for i in range(1,al-1,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        ans+=(m*(m+1)+n*(n-1))/2
    if al%2==0:
        ans+=a[-1]*(a[-1]+1)/2
print(int(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)
ans=[0]*(n+1)
m=0
for i in range(1,n+1):
	if s[i]=='<':
		ans[i]=ans[i-1]+1
	else:
		ans[i]=ans[i-1]-1
	m=min(m,ans[i])
print(sum(ans)-m*n)
		


s=str(input())
sl=len(s)+1
l,r=[0]*sl,[0]*sl
ss=[0]*sl
lcnt,rcnt=0,0
for i in range(sl):
  if i==0:
    l[0]=0
    r[sl-1]=0
  else:
    if s[i-1]=="<":
      lcnt+=1
    else:
      lcnt=0
    if s[sl-i-1]==">":
      rcnt+=1
    else:
      rcnt=0
    l[i]=lcnt
    r[sl-i-1]=rcnt
for i in range(sl):
  ss[i]=max(l[i],r[i])
print(sum(ss))

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=[0]*(len(s)+1)
for i in range(1,len(s)+1):
    a[i]=a[i-1]+i
R=L=0
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        if s[i]==">":
            R+=1
        else:L+=1
    else:
        if s[i]=="<":
            ans+=a[max(R,L)]+a[max(0,min(R,L)-1)]
            R=0
            L=1
        else:R+=1    
    print(ans,R,L)
print(ans+a[max(R,L)]+a[max(0,min(R,L)-1)])

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

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


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):
x2=1
y=0
for i in range(len(s)-1):
  if s[i+1]==s[i]:
    x2=x2+1
  else:
    if i==0:
      x2=0
    if s[i]=='>':
      if x2<x1:
        x2=x2-1
      else:
        if x2>x1:
          x1=x1-1
    y+=x1*(x1+1)/2
    x1=x2
    x2=1
if s[i+1]=='>':
      if x2<x1:
        x2=x2-1
      else:
        if x2>x1:
          x1=x1-1
y+=x1*(x1+1)/2
y+=x2*(x2+1)/2
print(int(y))

S=str(input())
s=list(S)
x1=0
x2=0
y=0
for i in range(len(s)-1):
  if s[i+1]==s[i]:
    print(x1,x2,y,"yes")
    x2=x2+1
  else:
    if s[i]=='>':
      print(i)
      if x2<x1:
        x2=x2-1
      else:
        if x2>x1:
          x1=x1-1
    y+=x1*(x1+1)/2
    print(x1,x2,y,"no")
    x1=x2
    x2=1
print(x1,x2,y)
if s[i+1]=='>':
      print(i)
      if x2<x1:
        x2=x2-1
      else:
        if x2>x1:
          x1=x1-1
y+=x1*(x1+1)/2
y+=x2*(x2+1)/2
print(x1,x2,y)
print(int(y))

import sys
sys.setrecursionlimit(2147483647) 
S=str(input())
s=list(S)
x1=0
x2=1
y=0
len=len(s)-1
for i in range(len):
  if s[i+1]==s[i]:
    x2=x2+1
  else:
    if i==0:
      x2=0
    if s[i]=='>':
      if x2<x1:
        x2=x2-1
      else:
          x1=x1-1
    y+=x1*(x1+1)/2
    x1=x2
    x2=1
if s[len]=='>':
  if x2<x1:
    x2=x2-1
  else:
    x1=x1-1
y+=x1*(x1+1)/2
y+=x2*(x2+1)/2
print(int(y))

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()
kei = 0
k = []
l = []
if S[0] == '<':
  k.append(0)
for i in range(len(S)-1):
  if S[i] == '>' and S[i+1] == '<':
    k.append(i+1)
  elif S[i] == '<' and S[i+1] == '>':
    l.append(i+1)
if S[len(S)] == '>':
  k.append(len(S)+1)
def summ(m):
  s = 0
  if m != 0:
    for j in range(1,m+1):
      s += j
  return s
for p in range(len(k)-1):
  if k[p+1] - l[p] > l[p] - k[p]:
    kei += summ(k[p+1] - l[p]) + summ(l[p]-k[p] - 1)
  else:
    kei += summ(k[p+1] - l[p] - 1) + summ(l[p]-k[p])
print(kei)   
  
  
  
  
  
  
  
  

S = input()
kei = 0
k = []
l = []
if S[0] == '<':
  k.append(0)
for i in range(len(S)-1):
  if S[i] == '>' and S[i+1] == '<':
    k.append(i+1)
  elif S[i] == '<' and S[i+1] == '>':
    l.append(i+1)
if S[-1] == '>':
  k.append(len(S)+1)
for p in range(len(k)-1):
  a = k[p+1]-l[p] 
  b = l[p] - k[p]
  if a > b :
    kei += a*(a+1)/2 + b*(b-1)/2
  else:
    kei += a*(a-1)/2 + b*(b+1)/2
print(kei)   
  
  
 

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 k in range(N-2,-1,-1):
  if s[k] == '>':
    l[k] = max(l[k], l[k+1] + 1)
print(sum(l))

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()
a = [0]*(len(S)+1)

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

print(ans)

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

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

print(ans)

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

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

print(ans)

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

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

print(ans)

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):
# ><
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()
L = []
LS = []
t = 1
t_str = ''
for i in range(len(S)-1):
    if i == 0:
        t = 1
        t_str = S[i]

    if t_str == S[i] and S[i]==S[i+1]:
        t += 1
    else:
        L.append(t)
        LS.append(t_str)
        t = 1
        t_str = S[i+1]
    
    if i == len(S)-2:
        L.append(t)
        LS.append(t_str)

# print(L)
odd = 0
even = 0
for i in range(len(L)):
    if i%2 == 0:
        odd = 0
        even = 0

        odd = L[i]
    
    if i%2 == 1:
        even = L[i]
        if odd < even:
            L[i-1] -= 1
        elif odd > even:
            L[i] -= 1

# print(L)
ans = 0
for i in range(len(L)):
    l = L[i]
    ans += (l*(l+1))/2
    if len(L)>1 and i !=len(L)-1:
        if i%2==0 and L[i]==L[i+1]:
            if LS[i]=='<':
                ans -= L[i]
    if i%2 == 1:
        if i == len(L)-1 and LS[i]=='>':
            ans -= L[i]


print(int(ans))


from itertools import groupby
s=input()
n=len(s)
s=list(s)
gr=groupby(s)
a=[]
for k,g in gr:
    a.append(len(list(g)))

ans=0
nn=len(a)
if s[0]=='<':
    for i in range(nn):
        if i%2==0:
            if i==nn-1:
                if nn%2==1:
                    ans+=a[i]*(a[i]+1)//2
                else:
                    t_max=max(a[i],a[i+1])
                    t_min=min(a[i],a[i+1])
                    t_min-=1
                    ans+=t_max*(t_max+1)//2
                    ans+=t_min*(t_min+1)//2
            else:
                t_max=max(a[i],a[i+1])
                t_min=min(a[i],a[i+1])
                t_min-=1
                ans+=t_max*(t_max+1)//2
                ans+=t_min*(t_min+1)//2                
else:
    for i in range(nn):
        if i==0:
            t_max=a[i]
            ans+=t_max*(t_max+1)//2
            continue
        if i%2==1:
            if i==nn-1:
                if nn%2==0:
                    ans+=a[i]*(a[i]+1)//2
                else:
                    t_max=max(a[i],a[i+1])
                    t_min=min(a[i],a[i+1])
                    t_min-=1
                    ans+=t_max*(t_max+1)//2
                    ans+=t_min*(t_min+1)//2
            else:
                t_max=max(a[i],a[i+1])
                t_min=min(a[i],a[i+1])
                t_min-=1
                ans+=t_max*(t_max+1)//2
                ans+=t_min*(t_min+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):
S = input()
n = len(S)
ans = [0]*(n+1)
for i in range(n):
    if S[i]=='<':
        ans[i]=ans[i-1]+1
for i in range(n-1,-1,-1):
    if S[i]==">":
        ans[i]=ans[i+1]+1
res = 0
for i in range(n+1):
    res+=ans[i]
print(res)


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


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


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

        ans[i+1]=ans[i]+1
    # print(ans)
# print(ans)
for i in range(n-1,-1,-1):
    if S[i]==">":
        if ans[i]>ans[i+1]:
            continue
        else:
            ans[i]=ans[i+1]+1
    # print(ans)
res = 0
for i in range(n+1):
    res+=ans[i]
# print(ans)
print(res)

Verdicts: Wrong Answer

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

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

Verdicts: Wrong Answer

Accepted