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


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

s = input()
n = len(s) + 1
a = [0 for i in range(n)]
for i in range(n - 1):
  if s[i] == '<':
    a[i + 1] = max(a[i + 1], a[i] + 1)
for i in reversed(range(n - 1)):
  if s[i] == '>':
    a[i] = max(a[i], a[i + 1] + 1)
ans = sum(a)
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=list(input())
n=len(s)+1
ans=[0]*n
for i in range(n-1):
    if s[i]=='<':
        ans[i+1]=ans[i]+1
    else:
        ans[i+1]=ans[i]-1
m=min(ans)
print(sum(ans)-m*n)

s=list(input())
n=len(s)+1
f=1
s.append('!')
y=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        f+=1
    else:
        y.append(f)
        f=1
if s[0]=='<':
    ans=0
    for i in range(len(y)-1):
        ans+=y[i]*(y[i]-1)//2
        if i%2==0:
            ans+=min(y[i],y[i+1])
    ans+=y[-1]*(y[-1]-1)//2
    print(ans)
else:
    ans=0
    for i in range(len(y)-1):
        ans+=y[i]*(y[i]-1)//2
        if i%2==1:
            ans+=min(y[i],y[i+1])
    print(ans+y[-1]*(y[-1]-1)//2)

s=list(input())
n=len(s)+1
f=1
s.append('!')
y=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        f+=1
    else:
        y.append(f)
        f=1
if len(y)==1:
    print(y[0]*(y[0]+1)//2)
    exit()
if s[0]=='<':
    ans=0
    for i in range(len(y)-1):
        ans+=y[i]*(y[i]-1)//2
        if i%2==0:
            ans+=max(y[i],y[i+1])
    if len(y)%2==0:
        ans+=y[-1]*(y[-1]-1)//2
    else:
        ans+=y[-1]*(y[-1]+1)//2
    print(ans)
else:
    ans=0
    for i in range(len(y)-1):
        if i==0:
            ans+=y[i]*(y[i]+1)//2
            continue
        ans+=y[i]*(y[i]-1)//2
        if i%2==1:
            ans+=max(y[i],y[i+1])
    if len(y)%2==0:
        ans+=y[-1]*(y[-1]+1)//2
    else:
        ans+=y[-1]*(y[-1]-1)//2
    print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is a string S of length N-1. Each character in S is `<` or `>`.  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be _good_ when the following condition is satisfied for all i (1 \leq i \leq N-1):    * If S_i= `<`: a_i<a_{i+1}   * If S_i= `>`: a_i>a_{i+1}  Find the minimum possible sum of the elements of a good sequence of N non- negative integers.

Submission attempts (in order):
s = input()
tmp = [0]
tmpsc = 1
tmpsum = 0
for i, a in enumerate(s):
    if a == '<':
        if i == 0:
            tmp.append(tmp[i] + 1)
        else:
            #if tmp[i] >= 0:
            if s[i-1] == '<':
                tmp.append(tmp[i] + 1)
                tmpsc = 1
            else:
                tmp.append(1)
                tmpsum += tmp[i] * tmpsc * -1
                tmpsc = 1

    else:
        tmp.append(tmp[i] - 1)
        tmpsc += 1

# print(tmpsc1,tmpsc2)
if s[-1] < '>':
    #print(tmp[-1],tmpsc)
    tmpsum += tmp[i] * tmpsc * -1
print(sum(tmp)+ tmpsum)

#print(tmp)

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is a string S of length N-1. Each character in S is `<` or `>`.  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be _good_ when the following condition is satisfied for all i (1 \leq i \leq N-1):    * If S_i= `<`: a_i<a_{i+1}   * If S_i= `>`: a_i>a_{i+1}  Find the minimum possible sum of the elements of a good sequence of N non- negative integers.

Submission attempts (in order):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


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


import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()
n = len(s)
a = [0] * (n + 1)
for i in range(len(s)):
    if '<' == s[i]:
        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)
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()
n = len(s) + 1
lis = [0] * n
if s[0] == "<":
  lis[0] = 0
p = 1
while p < n - 1:
  if s[p - 1] == ">" and s[p] == "<":
    lis[p] = 0
  elif s[p - 1] == "<" and s[p] == "<":
    lis[p] = max(lis[p - 1] + 1, lis[p])
  elif s[p] == ">":
    pass
  p += 1
    
if s[-1] == ">":
  lis[-2] = 1
  lis[-1] = 0
  
p = n - 3
while p >= 0:
  if s[p] == ">" and s[p + 1] == "<":
    if p - 1 >= 0:
      lis[p] = max(lis[p + 1] + 1, lis[p], lis[p - 1] + 1)
    else:
      lis[p] = 1
  elif s[p] == ">" and s[p + 1] == ">":
    if p - 1 >= 0:
      lis[p] = max(lis[p + 1] + 1, lis[p], lis[p - 1] + 1)
    else:
      lis[p] = max(lis[p + 1] + 1, lis[p])
  elif s[p] == "<":
    pass
  p -= 1

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

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

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N-1. Each character in S is `<` or `>`.  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be _good_ when the following condition is satisfied for all i (1 \leq i \leq N-1):    * If S_i= `<`: a_i<a_{i+1}   * If S_i= `>`: a_i>a_{i+1}  Find the minimum possible sum of the elements of a good sequence of N non- negative integers.

Submission attempts (in order):
s = input()
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(-1, -n, -1):
    if s[i] == '>':
        a[i-1] = max(a[i] + 1, a[i-1])
print(a)

s = input()
n = len(s)
a = [0]*(n+1)
for i in range(n):
    if s[i] == '<':
        a[i+1] = max(a[i] + 1, a[i+1])
for i in range(-1, -n-1, -1):
    if s[i] == '>':
        a[i-1] = max(a[i] + 1, a[i-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 = []
A.append(0)

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

for i in range(len(S)):
    if S[len(S) - i - 1] == ">":
        A[len(S) - i - 1] = max(A[len(S) - i - 1], A[len(S) - i] + 1)
    else:
        continue

print(A)
print(sum(A))


S = input()
A = []
A.append(0)

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

for i in range(len(S)):
    if S[len(S) - i - 1] == ">":
        A[len(S) - i - 1] = max(A[len(S) - i - 1], A[len(S) - i] + 1)
    else:
        continue

# 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):
S = input()
n = len(S) + 1
num = [0] * n
for i in range(n-1):
    if S[i] == '<':
        num[i + 1] = max(num[i] + 1, num[i + 1])
for i in range(n - 2, -1, -1):
    if S[i] == '>':
        num[i] = max(num[i + 1] + 1, num[i])
print(sum(num))
print(num)


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

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()
left = 0
cou = 0
l = [0 for i in range(len(s)+1)]
for i in range(len(s)):
  s1 = s[i]
  a1 = l[i]
#  print(s1,l,cou)
  if s1=='<':
    l[i+1] = l[i]+1
    left = 0
  else:
    l[i+1] = l[i]-1
    left += 1
    if l[i+1]>=0:
      l[i+1] = 0
      left = 0
    else:
      l[i+1] =0
      cou += left
print(cou+sum(l))
    

s = input()
left = 0
cou = 0
k = 0
l = [0 for i in range(len(s)+1)]
for i in range(len(s)):
  s1 = s[i]
  a1 = l[i]
#  print(s1,l,left,cou,k)
  if s1=='<':
    l[i+1] = l[i]+1
    left = 0
    k = l[i+1]
  else:
    l[i+1] = l[i]-1
    left += 1
    if l[i+1]>=0:
      l[i+1] = 0
    else:
      l[i+1] =0
      if k>=left:
        cou += left-1
      else:
        cou += left
print(cou+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()

count0, count1 = 0, 0
val = []
for i in range(len(S)):
    if S[i] == '<':
        count0 += 1
        if count1 != 0:
            val.append(count1)
        if i == len(S)-1:
            val.append(count0)
        count1 = 0
    else:
        count1 += 1
        if count0 != 0:
            val.append(count0)
        if i == len(S)-1:
            val.append(count1)
        count0 = 0
print(val)
ans = 0
for i in range(0, len(val)-1, 2):
    a = max(val[i], val[i+1])
    b = min(val[i], val[i+1])
    ans += a*(a+1)/2 + (b-1)*b/2
if len(val) % 2 == 1:
    a = max(val[-2], val[-1])
    #b = min(val[i], val[i+1])
    ans += a*(a+1)/2 #+ (b-1)*b/2    
print(int(ans))


S = input()

count0, count1 = 0, 0
val = []
first = '-'
for i in range(len(S)):
    if S[i] == '<' and i == 0:
        first = 'right'
    elif S[i] == '>' and i == 0:
        first == 'left'
        
    if S[i] == '<':
        count0 += 1
        if count1 != 0:
            val.append(count1)
        if i == len(S)-1:
            val.append(count0)
        count1 = 0
    else:
        count1 += 1
        if count0 != 0:
            val.append(count0)
        if i == len(S)-1:
            val.append(count1)
        count0 = 0

ans = 0
for i in range(0, len(val)-1, 2):
    a = max(val[i], val[i+1])
    b = min(val[i], val[i+1])
    ans += a*(a+1)/2 + (b-1)*b/2
if first == 'right':
    print(int(ans)+1)
else:
    print(int(ans))


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

for i in range(num):
    if s[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in range(1, num+1):
    print(a)
    if s[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
print(sum(a))


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

for i in range(num):
    if s[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in range(1, num+1):
    if s[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
print(sum(a))


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Given is a string S of length N-1. Each character in S is `<` or `>`.  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be _good_ when the following condition is satisfied for all i (1 \leq i \leq N-1):    * If S_i= `<`: a_i<a_{i+1}   * If S_i= `>`: a_i>a_{i+1}  Find the minimum possible sum of the elements of a good sequence of N non- negative integers.

Submission attempts (in order):
s = input()
b = s[0]
cou = 0
if len(s)==2:
    if s[0]=='>' and s[1] =='<':
        print(2)
        exit()

lis = []
for i in s:
    if b ==i:
        if i=='<':
            cou-=1
        else:
            cou+=1
    else:
        lis.append(cou)
        b = i
        if b=='<':
            cou =-1
        else:
            cou = 1
lis.append(cou)
l = len(lis)
sum = 0

for i in range(0,l,2):
    if i+1 == l and (i+1)%2==1:
        a = abs(lis[i])
        sum += a*(a+1)//2
        break
    a = abs(lis[i])
    b = abs(lis[i+1])

    if a < b:
		sum += b*(b+1)//2
		sum += (a-1)*a//2
    else:
        sum += a*(a+1)//2
        sum += (b-1)*b//2        
print(sum)

s = input()
b = s[0]
cou = 0


lis = []
for i in s:
    if b ==i:
        if i=='<':
            cou-=1
        else:
            cou+=1
    else:
        lis.append(cou)
        b = i
        if b=='<':
            cou =-1
        else:
            cou = 1
lis.append(cou)
l = len(lis)
sum = 0
if s[0]=='<':
    for i in range(0,l,2):
        if i+1 == l and (i+1)%2==1:
            a = abs(lis[i])
            sum += a*(a+1)//2
            break
        a = abs(lis[i])
        b = abs(lis[i+1])

        if a < b:
            sum += b*(b+1)//2
            sum += (a-1)*a//2
        else:
            sum += a*(a+1)//2
            sum += (b-1)*b//2
else:
    a = abs(lis[0])
    sum += a*(a+1)//2
    for i in range(1,l,2):
        if i+1 == l and (i+1)%2==0:
            a = abs(lis[i])
            sum += a*(a+1)//2
            break
        a = abs(lis[i])
        b = abs(lis[i+1])

        if a < b:
            sum += b*(b+1)//2
            sum += (a-1)*a//2
        else:
            sum += a*(a+1)//2
            sum += (b-1)*b//2

print(sum)


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) #length s
aa = ['.'] * (n + 1)

if s[0] == '<':
  aa[0] = 0

for i in range(n-1):
  if s[i] ==  '>' and s[i+1] == '<':
    aa[i+1] = 0 
  elif s[i] == '<' and s[i+1] == '>':
    aa[i+1] = n
    
id0 = [i for i,x in enumerate(aa) if x == 0]
idm = [i for i, x in enumerate(aa) if x == n]


for i in range(len(id0)-1):
  aa[idm[i]] = max(idm[i]-id0[i], id0[i+1]-idm[i])

for i in range(n):
  if s[i] == '<' and aa[i+1] == '.':
    aa[i+1] = aa[i] + 1
for i in range(n-1, 0,-1):
  if aa[i] == '.' and s[i] == '>':
    aa[i] = aa[i+1] +1

print(sum(aa))

s = input()
n = len(s) #length s
aa = ['.'] * (n + 1)

if s[0] == '<':
  aa[0] = 0
if s[-1] == '>':
  aa[-1] = 0

for i in range(n-1):
  if s[i] ==  '>' and s[i+1] == '<':
    aa[i+1] = 0 
  elif s[i] == '<' and s[i+1] == '>':
    aa[i+1] = n
    
z = [i for i,x in enumerate(aa) if x == 0]
m = [i for i, x in enumerate(aa) if x == n]


for i in range(len(z)-1):
  aa[m[i]] = max(m[i]-z[i], z[i+1]-m[i])
  aa[m[i]+1] = z[i+1]-m[i]-1
  for j in range(z[i]+1, m[i]):
    aa[j] = aa[j-1] +1
  for k in range(m[i]+2,z[i+1]):
    
    aa[k] = aa[k-1]-1
for i in range(z[-1], n+1):
  if aa[i] == '.':
    aa[i] = aa[i-1]+1
for i in range(z[0]):
  if aa[i] == '.':
    aa[i] = z[0] - i

s = input()
n = len(s) #length s
aa = ['.'] * (n + 1)

if s[0] == '<':
  aa[0] = 0
if s[-1] == '>':
  aa[-1] = 0

for i in range(n-1):
  if s[i] ==  '>' and s[i+1] == '<':
    aa[i+1] = 0 
  elif s[i] == '<' and s[i+1] == '>':
    aa[i+1] = n
    
z = [i for i,x in enumerate(aa) if x == 0]
m = [i for i, x in enumerate(aa) if x == n]


for i in range(len(z)-1):
  aa[m[i]] = max(m[i]-z[i], z[i+1]-m[i])
  aa[m[i]+1] = z[i+1]-m[i]-1
  for j in range(z[i]+1, m[i]):
    aa[j] = aa[j-1] +1
  for k in range(m[i]+2,z[i+1]):
    
    aa[k] = aa[k-1]-1
for i in range(z[-1], n+1):
  if aa[i] == '.':
    aa[i] = aa[i-1]+1
for i in range(z[0]):
  if aa[i] == '.':
    aa[i] = z[0] - i
    

print(sum(aa))

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
l = 0
r = 0
if s[0] == ">":
    p = 0
elif s[0] == "<":
    p = 1
for i in range(n-1):
    if p == 0:
        if s[i] == ">":
            l += 1
        elif s[i] == "<":
            p = 1
            ans += l*(l+1)//2
            if l < r:
                ans -= l
            elif l >= r:
                ans -= r 
            l = 0
            r = 1
    elif p == 1:
        if s[i] == "<":
            r += 1
        elif s[i] == ">":
            l += 1
            p = 0
            ans += r*(r+1)//2
if r != 0:
    ans += r*(r+1)//2

print(ans)

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

i = 0
while i < n - 1:
    uCount = 0 # '<'
    dCount = 0 # '>'
    while s[i] == '<' and i < n - 2:
        uCount += 1
        i += 1
    while s[i] == '>' and i < n - 2:
        dCount += 1
        i += 1
    if uCount > dCount:
        ans += sum(range(0, uCount + 1))
        ans += sum(range(0, dCount))
    elif uCount <= dCount:
        ans += sum(range(0, dCount + 1))
        ans += sum(range(0, uCount))
    if i == n - 2 and s[i] == '<':
        ans += 1
        i += 1
    elif i == n - 2 and s[i] == '>':
        i += 1
print(ans)


s = input()

n = len(s) + 1
a = [0] * n
for i in range(n - 1):
    if s[i] == '<':
        a[i + 1] = a[i] + 1

for i in range(n - 2, - 1, -1):
    if s[i] == '>':
        if a[i] <= a[i + 1] + 1:
            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):
import re

s = str(input())

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

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

s = s.split('0')

sum = 0

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

import re

s = str(input())

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

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

s = s.split('0')

sum = 0

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

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

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

total += count

print(total)


s=input()

list=[0 for _ in range(len(s) + 1)]

for n in range(0, len(s), 1):
    if '<' == s[n] and list[n] >= list[n + 1]:
        list[n + 1] += list[n] - list[n + 1] + 1

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

print(sum(list))


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

def calc_sum(n):
    if n <= 0:
        return 0
    return (n+1)*n/2

length = len(s)

num_g = 0
num_l = 0

prev = 1
cur = -1

out = 0

for i in range(length):
    if s[i] == '<':
        cur = 1
    else:
        cur = 0
        
    if prev == 1 and cur == 1:
        num_g += 1
    elif prev == 1 and cur == 0:
        num_l += 1
    elif prev == 0 and cur == 0:
        num_l += 1
    elif prev == 0 and cur == 1:
        out += calc_sum(max(num_g, num_l)) + calc_sum(min(num_g, num_l)-1)
        
        num_g = 1
        num_l = 0
    
    prev = cur
    
if cur == 1:
    out += calc_sum(num_g)
else:
    out += calc_sum(max(num_g, num_l)) + calc_sum(min(num_g, num_l)-1)
    
print(str(out))

s = input()

def calc_sum(n):
    if n <= 0:
        return 0
    return (n+1)*n/2

length = len(s)

num_g = 0
num_l = 0

prev = 1
cur = -1

out = 0

for i in range(length):
    if s[i] == '<':
        cur = 1
    else:
        cur = 0
        
    if prev == 1 and cur == 1:
        num_g += 1
    elif prev == 1 and cur == 0:
        num_l += 1
    elif prev == 0 and cur == 0:
        num_l += 1
    elif prev == 0 and cur == 1:
        out += calc_sum(max(num_g, num_l)) + calc_sum(min(num_g, num_l)-1)
        
        num_g = 1
        num_l = 0
    
    prev = cur
    
if cur == 1:
    out += calc_sum(num_g)
else:
    out += calc_sum(max(num_g, num_l)) + calc_sum(min(num_g, num_l)-1)
    
print(str(int(out)))

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):
n=int(input())
a=input()
p=0
q=0
r=0
i=0
while i<n-1:
  while a[i]=="<":
    i+=1
    p+=1
    if i==n-1:
      print(r+p*(p+1)//2)
      exit(0)
  while a[i]==">":
    i+=1
    q+=1
    if i==n-1:
      break
  r+=p*(p+1)//2+q*(q+1)//2-min(p,q)
  p=0
  q=0
print(r)

a=input()
n=len(a)
p=0
q=0
r=0
i=0
while i<n:
  while a[i]=="<":
    i+=1
    p+=1
    if i==n:
      print(r+p*(p+1)//2)
      exit(0)
  while a[i]==">":
    i+=1
    q+=1
    if i==n:
      break
  r+=p*(p+1)//2+q*(q+1)//2-min(p,q)
  p=0
  q=0
print(r)

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())
N = len(S)+1
cnt = [0] * N
j = 0
k = 0

for i in range(N-2):
    if S[i] == S[i+1]:
        k += 1
    
    else:
        k += 1
        cnt[j] = k
        j += 1
        k = 0

if S[N-2] == S[N-3]:
    cnt[j] = k + 1
else:
    cnt[j] = 1

print(cnt)
ans = 0
if S[0] == "<":
    st = 0
else:
    ans += cnt[0]*(cnt[0]+1)//2
    st = 1

for k in range(st,N,2):
    if cnt[k] != 0:
        m = min(cnt[k],cnt[k+1])
        M = max(cnt[k],cnt[k+1])
        ans += m*(m-1)//2 + M*(M+1)//2 
    else:
        break
print(ans)

S = list(input())
N = len(S)+1
cnt = [0] * N
j = 0
k = 0

for i in range(N-2):
    if S[i] == S[i+1]:
        k += 1
    
    else:
        k += 1
        cnt[j] = k
        j += 1
        k = 0

if S[N-2] == S[N-3]:
    cnt[j] = k + 1
else:
    cnt[j] = 1

ans = 0
if S[0] == "<":
    st = 0
else:
    ans += cnt[0]*(cnt[0]+1)//2
    st = 1

for k in range(st,N,2):
    if cnt[k] != 0:
        m = min(cnt[k],cnt[k+1])
        M = max(cnt[k],cnt[k+1])
        ans += m*(m-1)//2 + M*(M+1)//2 
    else:
        break
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

#input = sys.stdin.readline
import math


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True


def main():
#    h,w,a,b = map(int, input().split())
    s = input()
    a = [0]*(len(s)+1)
    print(a)
    a[0] = 0
    temp = 0
    for i in range(len(s)):
        if s[i] == "<":
            a[i + 1] = a[i]+ 1
            if temp>0:
                for j in range(temp+1):
                    a[i - j] = max(0 + j,a[i-j])
            temp = 0
        elif s[i] == ">" and i < len(s)-1:
            temp += 1
        else:
            temp+=1
            for j in range(temp):
                a[i - j] = 0 + j + 1

    b = 0
    for i in range(len(a)):
        b += a[i]
    print(a)
    print(b)




if __name__ == "__main__":
    main()

#import sys

#input = sys.stdin.readline
import math


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True


def main():
#    h,w,a,b = map(int, input().split())
    s = input()
    a = [0]*(len(s)+1)
    print(a)
    a[0] = 0
    temp = 0
    for i in range(len(s)):
        if s[i] == "<":
            a[i + 1] = a[i]+ 1
            if temp>0:
                for j in range(temp+1):
                    a[i - j] = max(0 + j,a[i-j])
            temp = 0
        elif s[i] == ">" and i < len(s)-1:
            temp += 1
        else:
            temp+=1
            for j in range(temp):
                a[i - j] = 0 + j + 1

    b = 0
    for i in range(len(a)):
        b += a[i]

    print(b)




if __name__ == "__main__":
    main()

#import sys

#input = sys.stdin.readline
import math


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True


def main():
#    h,w,a,b = map(int, input().split())
    s = input()
    a = [0]*(len(s)+1)

    a[0] = 0
    temp = 0
    for i in range(len(s)):
        if s[i] == "<":
            a[i + 1] = a[i]+ 1
            if temp>0:
                for j in range(temp+1):
                    a[i - j] = max(0 + j,a[i-j])
            temp = 0
        elif s[i] == ">" and i < len(s)-1:
            temp += 1
        else:
            temp+=1
            for j in range(temp):
                a[i - j] = 0 + j + 1

    b = 0
    for i in range(len(a)):
        b += a[i]

    print(b)




if __name__ == "__main__":
    main()

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):
from itertools import*
s=input()


x=[len(list(v)) for k,v in groupby(s)]

n=len(x)

ans=0
if s[0]=="<":
    ans+=(x[0]-1)*x[0]//2
    n-=1
    del x[0]
if s[-1]==">":
    ans+=(x[-1]-1)*x[-1]//2
    n-=1
for i in range(0,n,2):
    ma=max(x[i],x[i+1])
    mi=min(x[i],x[i+1])
    ans+=ma*(ma+1)//2
    ans+=(mi-1)*mi//2
print(ans)

from itertools import*
s=input()


x=[len(list(v)) for k,v in groupby(s)]

n=len(x)

ans=0
if s[0]==">":
    ans+=(x[0]+1)*x[0]//2
    n-=1
    del x[0]
if s[-1]=="<":
    ans+=(x[-1]+1)*x[-1]//2
    n-=1
for i in range(0,n,2):
    ma=max(x[i],x[i+1])
    mi=min(x[i],x[i+1])
    ans+=ma*(ma+1)//2
    ans+=(mi-1)*mi//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
input = sys.stdin.readline
s = list(input())

l = [0]*(len(s)+1)
c = 0
for i in range(len(s)):
  if s[i] == "<":
    c += 1
  else:
    c -= 1
  l[i+1] = c

m = min(l)
ans= 0
for i in range(len(l)):
  ans += l[i] - m

print(ans)

    
  



import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

s = readline().rstrip().decode('utf-8')
n = len(s)
count = 0
lst1 = [0]*(n+1)
lst2 = [0]*(n+1)

for i in range(n):
	if s[i] == "<":
		lst1[i+1] = lst1[i]+1
for i in range(n-1,-1,-1):
	if s[i] == ">":
		lst2[i] = lst2[i+1]+1

ans = 0
for i in range(n+1):
	ans += max(lst1[i],lst2[i])

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N-1. Each character in S is `<` or `>`.  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be _good_ when the following condition is satisfied for all i (1 \leq i \leq N-1):    * If S_i= `<`: a_i<a_{i+1}   * If S_i= `>`: a_i>a_{i+1}  Find the minimum possible sum of the elements of a good sequence of N non- negative integers.

Submission attempts (in order):
s = input() + "<"

a = 0
b = 0
ans = 0
pre = s[0]

for i in s:
    print(ans, a, b)
    if i == ">":
        a += 1
        if pre == "<":
            ans += ((1 + b - 1) * (b - 1)) // 2
        pre = i
    if i == "<":
        if pre == ">":
            if b <= a:
                ans += ((1 + a) * a) // 2
            else:
                ans += ((1 + a - 1) * (a - 1)) // 2 + b
            a = 0
            b = 0
        b += 1
        pre = i
if i == "<":
    ans += ((1 + b - 1) * (b - 1)) // 2
print(ans)

s = input() + "<"

a = 0
b = 0
ans = 0
pre = s[0]

for i in s:
    if i == ">":
        a += 1
        if pre == "<":
            ans += ((1 + b - 1) * (b - 1)) // 2
        pre = i
    if i == "<":
        if pre == ">":
            if b <= a:
                ans += ((1 + a) * a) // 2
            else:
                ans += ((1 + a - 1) * (a - 1)) // 2 + b
            a = 0
            b = 0
        b += 1
        pre = i
if i == "<":
    ans += ((1 + b - 1) * (b - 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)
l = [0] * (N + 1)

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

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


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

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

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

for i in range(len(S)):
    if S[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)
        print(a)

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

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

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

for i in range(1, len(S)+1):
    if S[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+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()
N=len(S)
L=[0]*(N+1)
for i in range(len(S)):
    if S[i]=="<":
        L[i+1]+=L[i]+1

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

S=input()
N=len(S)
L=[0]*(N+1)
for i in range(len(S)):
    if S[i]=="<":
        L[i+1]+=L[i]+1

for i in range(len(S)-1,-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()
<_cnt = 0
>_cnt = 0
for i in range(len(s)):
  if s[i] == '<' and >_cnt == 0:
    <_cnt += 1
  elif s[i] == '<' and >_cnt > 0:
    k = max(<_cnt, >_cnt)
    l = min(<_cnt, >_cnt)
    total += (k+1)*k//2 + l*(l-1)//2
    <_cnt = 1
    >_cnt = 0
  elif s[i] == '>':
    >_cnt += 1
k = max(<_cnt, >_cnt)
l = min(<_cnt, >_cnt)
total += (k+1)*k//2 + l*(l-1)//2
print(total)
    

s = input()
<_cnt = 0
>_cnt = 0
total = 0
for i in range(len(s)):
  if s[i] == '<' and >_cnt == 0:
    <_cnt += 1
  elif s[i] == '<' and >_cnt > 0:
    k = max(<_cnt, >_cnt)
    l = min(<_cnt, >_cnt)
    total += (((k+1)*k) + (l*(l-1)))//2
    <_cnt = 1
    >_cnt = 0
  elif s[i] == '>':
    >_cnt += 1
k = max(<_cnt, >_cnt)
l = min(<_cnt, >_cnt)
total += (((k+1)*k) + (l*(l-1)))//2
print(total)

s = input()
<_cnt = 0
>_cnt = 0
total = 0
for i in range(len(s)):
  if s[i] == '<' and >_cnt == 0:
    <_cnt += 1
  elif s[i] == '<' and >_cnt > 0:
    k = max(<_cnt, >_cnt)
    l = min(<_cnt, >_cnt)
    total += (k+1)*k//2 + l*(l-1)//2
    <_cnt = 1
    >_cnt = 0
  elif s[i] == '>':
    >_cnt += 1
k = max(<_cnt, >_cnt)
l = min(<_cnt, >_cnt)
total += (k+1)*k//2 + l*(l-1)//2
print(total)
    


s = input()
right_cnt = 0
left_cnt = 0
total = 0
for i in range(len(s)):
  if s[i] == '<' and left_cnt == 0:
    right_cnt += 1
  elif s[i] == '<' and left_cnt > 0:
    k = max(right_cnt, left_cnt)
    l = min(right_cnt, left_cnt)
    total += (((k+1)*k) + (l*(l-1)))//2
    right_cnt = 1
    left_cnt = 0
  elif s[i] == '>':
    left_cnt += 1
k = max(right_cnt, left_cnt)
l = min(right_cnt, left_cnt)
total += (((k+1)*k) + (l*(l-1)))//2
print(total)


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

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

print(sum_a)

import sys
input = sys.stdin.readline

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

print(sum_a)

import sys
input = sys.stdin.readline

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

print(sum_a)


import sys
input = sys.stdin.readline

S = input().strip()
N = len(S) + 1
incre = [0] * N
decre = [0] * N
sum_a = 0

t = 0
for i, s in enumerate(S):
    if s == '<':
        t += 1
        incre[i + 1] = t
    else:
        t = 0

t = 0
for i, s in enumerate(S[::-1]):
    if s == '>':
        t += 1
        decre[-(i + 2)] = t
    else:
        t = 0

for i, (inc, dec) in enumerate(zip(incre, decre)):
    if inc < dec:
        incre[i] = dec

print(sum(incre))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given is a string S of length N-1. Each character in S is `<` or `>`.  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be _good_ when the following condition is satisfied for all i (1 \leq i \leq N-1):    * If S_i= `<`: a_i<a_{i+1}   * If S_i= `>`: a_i>a_{i+1}  Find the minimum possible sum of the elements of a good sequence of N non- negative integers.

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

tmp1 = [0 for _ in range(len(S)+1)]
tmp2 = [0 for _ in range(len(S)+1)]

for i in range(len(S)):
  if S[i] == '>':
    tmp1[i] = 1
  else:
    tmp2[i+1] = 1

for i in range(1, len(S)+1):
  if tmp1[-i-1] != 0:
    tmp1[-i-1] = tmp1[-i] + tmp1[-i-1]

for i in range(2, len(S)):
  if tmp2[i] != 0:
    tmp2[i] = tmp2[i] + tmp2[i-1]

ans = 0
for i in range(len(S)):
  ans += max(tmp1[i], tmp2[i])

print(ans+1)

S = input()

tmp1 = [0 for _ in range(len(S)+1)]
tmp2 = [0 for _ in range(len(S)+1)]

for i in range(len(S)):
  if S[i] == '>':
    tmp1[i] = 1
  else:
    tmp2[i+1] = 1

for i in range(1, len(S)+1):
  if tmp1[-i-1] != 0:
    tmp1[-i-1] = tmp1[-i] + tmp1[-i-1]

for i in range(2, len(S)+1):
  if tmp2[i] != 0:
    tmp2[i] = tmp2[i] + tmp2[i-1]

ans = 0
for i in range(len(S)+1):
  ans += max(tmp1[i], tmp2[i])

print(ans)



Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N-1. Each character in S is `<` or `>`.  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be _good_ when the following condition is satisfied for all i (1 \leq i \leq N-1):    * If S_i= `<`: a_i<a_{i+1}   * If S_i= `>`: a_i>a_{i+1}  Find the minimum possible sum of the elements of a good sequence of N non- negative integers.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10**9)

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

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

import sys
sys.setrecursionlimit(10**9)

s = str(input())
c = s[0]
ran = [1]
for i in range(1, len(s)):
    if c == s[i]:
        ran[-1] += 1
    else:
        ran.append(1)
        c = s[i]

result = ran[0]
if s[0] == '<':
    result = ((ran[0]-1)*ran[0])//2
    h = True
else:
    result = ((1+ran[0])*ran[0])//2
    h = False
if len(ran) == 1:
    result = ((1+ran[0])*ran[0])//2

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

Verdicts: Wrong Answer

Accepted