ZhenlongDai/ACPR huggingface dataset:
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
def till_sum(n):
    return((n) * (n - 1) / 2)
s = list(input())
count = 0
ls = []
for i in range(len(s)):
    count += 1
    if len(s) - 1 == i:
        break
    else:
        if s[i] != s[i+1]:
            ls.append(count)
            count = 0
ls.append(count)
print(ls)
result = sum(map(till_sum, ls))
for i in range(math.ceil(len(ls)/2)):
    if len(ls) - 1 == 2*i:
        result += ls[2*i]
    else:
        if ls[2*i] < ls[2*i + 1]:
            result += ls[2*i + 1]
        if ls[2*i] >= ls[2*i + 1]:
            result += ls[2*i]
print(int(result))


Failing test case input:
<<>>>><<<<<>>><<

Expected output:
32


Actual output:
[2, 4, 5, 3, 2]
32


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

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
L = input()
L = list(L.split('><'))
if len(L) == 1:
    ans = len(L)*(len(L)+1)/2
else:
    ans = 0
    for i in range(len(L)):
        if i == 0:
            a = [L[i].count('<'),L[i].count('>')+1]
        elif i == len(L)-1:
            a = [L[i].count('<')+1,L[i].count('>')]
        else:
            a = [L[i].count('<')+1,L[i].count('>')+1]
        a_max = max(a)
        a_min = min(a)

        ans += a_max*(a_max+1)/2
        ans += a_min*(a_min-1)/2

print(int(ans))


Failing test case input:
<>>

Expected output:
3

Actual output:
1


Fixed submission (verdict: Accepted):
L = input()
L = list(L.split('><'))
if len(L) == 1:
    a = [L[0].count('<'),L[0].count('>')]
    a_max = max(a)
    ans = a_max*(a_max+1)/2
else:
    ans = 0
    for i in range(len(L)):
        if i == 0:
            a = [L[i].count('<'),L[i].count('>')+1]
        elif i == len(L)-1:
            a = [L[i].count('<')+1,L[i].count('>')]
        else:
            a = [L[i].count('<')+1,L[i].count('>')+1]
        a_max = max(a)
        a_min = min(a)

        ans += a_max*(a_max+1)/2
        ans += a_min*(a_min-1)/2

print(int(ans))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
<>>><<><><<<>><<

Expected output:
20


Actual output:
[0, 3, 2, 1, 0, 1, 2, 0, 1, 0, 1, 2, 3, 1, 0, 1, 2]


Fixed submission (verdict: Accepted):
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))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
<<>><>><>>><<<<<

Expected output:
28


Actual output:
20


Fixed submission (verdict: Accepted):
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)

Problem: p02873
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S=input()
N=len(S)+1
llst=[0 for i in range(N)]
rlst=[0 for i in range(N)]
for i in range(N-1):
  if S[i]=='<':
    llst[i+1]=llst[i]+1
for i in range(N-2, 0, -1):
  if S[i]=='>':
    rlst[i]=rlst[i+1]+1
ans=0
for i in range(N):
  ans+=max(llst[i], rlst[i])
print(ans)

Failing test case input:
><<<<<><><><>>><

Expected output:
25


Actual output:
24


Fixed submission (verdict: Accepted):
S=input()
N=len(S)+1
llst=[0 for i in range(N)]
rlst=[0 for i in range(N)]
for i in range(N-1):
  if S[i]=='<':
    llst[i+1]=llst[i]+1
for i in range(N-2, -1, -1):
  if S[i]=='>':
    rlst[i]=rlst[i+1]+1
ans=0
for i in range(N):
  ans+=max(llst[i], rlst[i])
print(ans)

Problem: p02873
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()

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

print(sum(A))


Failing test case input:
>>>><<><<<<<<>><

Expected output:
36


Actual output:
32


Fixed submission (verdict: Accepted):
S=input()

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

print(sum(A))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

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


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



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

print(sum)
    

Failing test case input:
<<><<<>><>><>><<

Expected output:
19


Actual output:
17


Fixed submission (verdict: Accepted):
S = input()


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

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


count = 1
s_list[len(s_list)-1] = 0 if s_list[len(s_list)-1] < 0 else s_list[len(s_list)-1] 

for i in range(len(S)-1,0,-1):
    if S[i] == ">" and S[i-1] == ">":
    
        s_list[i] = count
        count += 1
    elif S[i] == ">" and S[i-1] == "<":
        s_list[i] = max(s_list[i-1], s_list[i+1]) + 1
    else:
        count = 1

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




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

print(sum)

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
n = len(S) + 1
a = [0] * n

S = ('<' if S[0] == '>' else '<') + S \
    + ('<' if S[-1] == '>' else '<') 

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

print(sum(a))

Failing test case input:
<<><<<><<>><>>><

Expected output:
20


Actual output:
18


Fixed submission (verdict: Accepted):
S = input()
n = len(S) + 1
a = [0] * n

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

print(sum(a))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input().strip()
count=1
a=[]
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        count=count+1
    else:
        a.append(count)
        count=1
    
if S[len(S)-1]!=S[len(S)-2]:
    a.append(1)
else:
    a.append(count)
sa=0
for i in range(len(a)-1):
    if S[0]=='<':
        if i%2==0:
            sa=sa+abs(a[i]-a[i+1])
    else:
        if i%2==1:
            sa=sa+abs(a[i]-a[i+1])
wa=0
for i in range(len(a)):
    wa=wa+((a[i]+1)*a[i]/2)
print(int(wa-sa))

Failing test case input:
<>><><<<<<><>><>

Expected output:
23


Actual output:
22


Fixed submission (verdict: Accepted):
S = input().strip()
count=1
a=[]
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        count=count+1
    else:
        a.append(count)
        count=1
    
if S[len(S)-1]!=S[len(S)-2]:
    a.append(1)
else:
    a.append(count)
sa=0
for i in range(len(a)-1):
    if S[0]=='<':
        if i%2==0:
            sa=sa+min(a[i],a[i+1])
    else:
        if i%2==1:
            sa=sa+min(a[i],a[i+1])
wa=0
for i in range(len(a)):
    wa=wa+((a[i]+1)*a[i]/2)
print(int(wa-sa))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

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


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

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

print(sum(ans))


Failing test case input:
<<>>><<<<><>>><<

Expected output:
26


Actual output:

25


Fixed submission (verdict: Accepted):
S = input()

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


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

    
ans.reverse()
for i in range(len(S)):
    
    
    
    
    if S[len(S)-1-i] == ">" and not ans[i] < ans[i+1]:
        ans[i + 1] = ans[i] + 1
        prev = ">"
    

print(sum(ans))
Problem: p02873
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = str(input())
ans = 0
def leftmore(ln):
    ret = [0]
    cur = 0
    for c in ln:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    return ret

def rightless(ln):
    revl = reversed(ln)
    ret = [0]
    cur = 0
    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        ret.append(cur)
    return list(reversed(ret))

lm = leftmore(s)
rl = rightless(s)
print(lm)
print(rl)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)

Failing test case input:
<>>>><<<>><<><<<

Expected output:
26


Actual output:
[0, 1, 0, 0, 0, 0, 1, 2, 3, 0, 0, 1, 2, 0, 1, 2, 3]
[0, 4, 3, 2, 1, 0, 0, 0, 2, 1, 0, 0, 1, 0, 0, 0, 0]
26


Fixed submission (verdict: Accepted):
s = str(input())

ans = 0
def leftmore(ln):
    ret = [0]
    cur = 0
    for c in ln:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    return ret

def rightless(ln):
    revl = reversed(ln)
    ret = [0]
    cur = 0
    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        ret.append(cur)
    return list(reversed(ret))

lm = leftmore(s)
rl = rightless(s)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)

Problem: p02873
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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-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))

Failing test case input:
><>><<><<<<><>><

Expected output:
21


Actual output:
2


Fixed submission (verdict: Accepted):
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))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
l=len(s)
a=[0 for i in range(l+1)]
for i in range(l):
    if s[i]=='<':
        a[i+1]=max(a[i+1],a[i]+1)
        print(a)
for i in range(l-1,-1,-1):
    if s[i]=='>':
        a[i]=max(a[i+1]+1,a[i])
        print(a)
print(sum(a))

Failing test case input:
<>><><><<<><>><<

Expected output:
17


Actual output:
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 0, 0, 0]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 0, 1, 0]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 0, 1, 2]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 1, 0, 1, 2]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 2, 1, 0, 1, 2]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 2, 1, 0, 1, 2]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 2, 1, 0, 1, 2]
[0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 2, 1, 0, 1, 2]
[0, 1, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 2, 1, 0, 1, 2]
[0, 2, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 2, 1, 0, 1, 2]
17


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

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=list(input())

s=0
f=0
g=0
h=0
for i in range(len(S)):
    if S[i]==">":
        g=0
        f+=1
        if f!=1:
            if h>=f:
                s+=f-1
            else:
                s+=f
        
    else:
        f=0
        g+=1
        s+=g
        h=g

print(s)


Failing test case input:
><>><<>><<<<<>><

Expected output:
25


Actual output:
24


Fixed submission (verdict: Accepted):
S=list(input())

s=0
f=0
g=0
h=0
for i in range(len(S)):
    if S[i]==">":
        g=0
        f+=1
        if h>=f:
            s+=f-1
        else:
            s+=f
        
    else:
        f=0
        g+=1
        s+=g
        h=g

print(s)
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from operator import itemgetter
input = sys.stdin.readline

_s = input()


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

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

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

    print(int(minisum))


chker(_s)


Failing test case input:
<>>>>><<<><<<<<>

Expected output:
36


Actual output:
37


Fixed submission (verdict: Accepted):
import sys
from operator import itemgetter
input = sys.stdin.readline

_s = input()


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

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

    print(int(minisum))


chker(_s)

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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):
    if s[i] == '>':
        a[i-1] = max(a[i] + 1, a[i-1])
print(sum(a))

Failing test case input:
><<<><<<<<>>>>><

Expected output:
33


Actual output:
32


Fixed submission (verdict: Accepted):
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))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(input())
A = [0] * (len(S)+1)
imos = [0] * (len(S))
for i in range(len(S)):
    if S[i] == '>':
        imos[i] = 1
    else:
        imos[i] = -1
imos += [0]
for i in range(len(S), 0, -1):
    imos[i-1] = max(0, imos[i-1] + imos[i])

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


Failing test case input:
<<>><><<<><><>><

Expected output:
16


Actual output:
19


Fixed submission (verdict: Accepted):
S = list(input())
A = [0] * (len(S)+1)
imos = [0] * (len(S))
for i in range(len(S)):
    if S[i] == '>':
        imos[i] = 1
    else:
        imos[i] = -10000000
imos += [0]
for i in range(len(S), 0, -1):
    imos[i-1] = max(0, imos[i-1] + imos[i])
A[0] = imos[0]
for i in range(len(S)):
    if S[i] == '<':
        A[i+1] = max(imos[i+1], A[i]+1)
    else:
        A[i+1] = max(0, min(A[i]-1, imos[i+1]))
print(sum(A))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(input())
A = [0] * (len(S)+1)
imos = [0] * (len(S))
for i in range(len(S)):
    if S[i] == '>':
        imos[i] = 1
    else:
        imos[i] = -10000000
imos += [0]
for i in range(len(S), 0, -1):
    imos[i-1] = max(0, imos[i-1] + imos[i])

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


Failing test case input:
><><><<<<<<<>>>>

Expected output:
37


Actual output:
36


Fixed submission (verdict: Accepted):
S = list(input())
A = [0] * (len(S)+1)
imos = [0] * (len(S))
for i in range(len(S)):
    if S[i] == '>':
        imos[i] = 1
    else:
        imos[i] = -10000000
imos += [0]
for i in range(len(S), 0, -1):
    imos[i-1] = max(0, imos[i-1] + imos[i])
A[0] = imos[0]
for i in range(len(S)):
    if S[i] == '<':
        A[i+1] = max(imos[i+1], A[i]+1)
    else:
        A[i+1] = max(0, min(A[i]-1, imos[i+1]))
print(sum(A))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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

print(int(count))


Failing test case input:
<<>>>><<<><><><<

Expected output:
22


Actual output:
21


Fixed submission (verdict: Accepted):

import math
s = input()
bigger=0
smaller=0
count = 0
bigger=1 if s[0]=="<" else 0 
smaller=1 if s[0]==">" else 0 


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

print(int(count))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

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

print(ans)

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


Failing test case input:
<<>>>><><<<<>><<

Expected output:
26


Actual output:
[0, 1, 2, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 0, 0, 1, 2]
[0, 1, 4, 3, 2, 1, 0, 1, 0, 1, 2, 3, 4, 1, 0, 1, 2]
26


Fixed submission (verdict: Accepted):
S = input()

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

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

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
arr = [0]
for i in range(len(s)):
  if s[i] == '<':
    arr.append(arr[i]+1)
  else:
    arr.append(0)

for i in reversed(range(len(s))):
  if s[i] == '>':
    arr[i] = max(arr[i],arr[i+1]+1)
print(sum(arr))
print(arr)

Failing test case input:
<<>><><<<><><>><

Expected output:
16


Actual output:
16
[0, 1, 2, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 2, 1, 0, 1]


Fixed submission (verdict: Accepted):
s = input()
arr = [0]
for i in range(len(s)):
  if s[i] == '<':
    arr.append(arr[i]+1)
  else:
    arr.append(0)

for i in reversed(range(len(s))):
  if s[i] == '>':
    arr[i] = max(arr[i],arr[i+1]+1)
print(sum(arr))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
for_l = [0] * (len(s) + 1)
for_r = [0] * (len(s) + 1)
l = [0] * (len(s) + 1)
for i in range(1, len(for_l)):
    if s[i - 1] == "<":
        for_l[i] = for_l[i - 1] + 1
    else:
        for_l[i] = 0
for i in range(1, len(for_l)):
    if s[-i] == ">":
        for_r[-i-1] = for_r[-i] + 1
    else:
        for_r[i] = 0
for i in range(len(for_l)):
    l[i] = max(for_l[i], for_r[i])
print(sum(l))

Failing test case input:
<>><<<>><<<>><><

Expected output:
19


Actual output:
18


Fixed submission (verdict: Accepted):
s = input()
for_l = [0] * (len(s) + 1)
for_r = [0] * (len(s) + 1)
l = [0] * (len(s) + 1)
for i in range(1, len(for_l)):
    if s[i - 1] == "<":
        for_l[i] = for_l[i - 1] + 1
for i in range(1, len(for_l)):
    if s[-i] == ">":
        for_r[-i-1] = for_r[-i] + 1
for i in range(len(for_l)):
    l[i] = max(for_l[i], for_r[i])
print(sum(l))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    n=len(s)
    A=[0]*(n+1)
    for i in range(0,n):
        if s[i]=="<":
            A[i+1]=A[i]+1
    for i in range(n,1,-1):
        if s[i-1]==">":
            A[i-1]=max(A[i-1],A[i]+1)
    print(sum(A))

if __name__=='__main__':
    main()

Failing test case input:
><>

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    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):
        if s[n-i-1]==">":
            A[n-i-1]=max(A[n-i-1],A[n-i]+1)
    print(sum(A))

if __name__=='__main__':
    main()

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
L = input()
L = list(L.split('><'))

ans = 0
for i in range(len(L)):
    if i == 0:
        a = [L[i].count('<'),L[i].count('>')+1]
    elif i == len(L)-1:
        a = [L[i].count('<')+1,L[i].count('>')]
    else:
        a = [L[i].count('<')+1,L[i].count('>')+1]
    a_max = max(a)
    a_min = min(a)

    ans += a_max*(a_max+1)/2
    ans += a_min*(a_min-1)/2

print(int(ans))


Failing test case input:
<>>

Expected output:
3

Actual output:
6


Fixed submission (verdict: Accepted):
L = input()
L = list(L.split('><'))
if len(L) == 1:
    a = [L[0].count('<'),L[0].count('>')]
    a_max = max(a)
    ans = a_max*(a_max+1)/2
else:
    ans = 0
    for i in range(len(L)):
        if i == 0:
            a = [L[i].count('<'),L[i].count('>')+1]
        elif i == len(L)-1:
            a = [L[i].count('<')+1,L[i].count('>')]
        else:
            a = [L[i].count('<')+1,L[i].count('>')+1]
        a_max = max(a)
        a_min = min(a)

        ans += a_max*(a_max+1)/2
        ans += a_min*(a_min-1)/2

print(int(ans))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
<<>>><><<<<><>><

Expected output:
22


Actual output:

Fixed submission (verdict: Accepted):
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)
Problem: p02873
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S = input()
N = len(S)
tmp = 1
List = []
for i in range(1, N):
    if S[i] != S[i-1]:
        List.append(tmp)
        tmp = 1
    else:
        tmp+=1
List.append(tmp)
ans = 0
if S[0] == '<':
    for i in range(0, len(List)-1, 2):
        r = List[i]
        l = List[i+1]
        ans+=r*(r-1)
        ans+=max(r, l)
        ans+=l*(l-1)
    if len(List)%2 == 1:
        ans+=List[-1]
    print(ans)
else:
    ans+=List[0]
    for i in range(1, len(List)-1, 2):
        r = List[i]
        l = List[i+1]
        ans+=r*(r-1)
        ans+=max(r, l)
        ans+=l*(l-1)
    if len(List)%2 == 0:
        ans += List[-1]
    print(ans)

Failing test case input:
<>><<<><<>><><><

Expected output:
16


Actual output:
22


Fixed submission (verdict: Accepted):
S = input()
N = len(S)
tmp = 1
List = []
for i in range(1, N):
    if S[i] != S[i-1]:
        List.append(tmp)
        tmp = 1
    else:
        tmp+=1
List.append(tmp)
def solve(ans, List):
    for i in range(0, len(List)-1, 2):
        r = List[i]
        l = List[i+1]
        ans+=r*(r-1)
        ans+=max(r, l)
        ans+=l*(l-1)
    if len(List)%2 == 1:
        l = List[-1]
        ans+=l*(l+1)
    print(ans)
if S[0] == '<':
    solve(0, List)
else:
    l = List[0]
    solve(l*(l+1)

Problem: p02873
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
a = [0]*(len(s)+1)

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

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

print(sum(a))


Failing test case input:
<>><><<<<<<<>>>>

Expected output:
38


Actual output:
35


Fixed submission (verdict: Accepted):
s = input()
a = [0]*(len(s)+1)

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

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

print(sum(a))

Problem: p02873
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


s = input()

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

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

print(sum(a))

Failing test case input:
><>

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):


s = input()

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

print(sum(a))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():

    S = input()
    i = 0
    cnt = []
    while i < len(S):
        ref = S[i]
        c = 0
        while i < len(S) and S[i] == ref:
            c += 1
            i += 1
        cnt.append(c)

    
    ans = 0
    if S[0] == ">":
        ans += cnt[0] * (cnt[0] + 1) 
    cnt.pop(0)

    for i in range(len(cnt)):
        if i % 2 == 0:
            ans += cnt[i] * (cnt[i] + 1) 
        else:
            if cnt[i] > cnt[i-1]:
                ans += cnt[i] - cnt[i-1]
            ans += cnt[i] * (cnt[i] - 1) 

    return ans

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

Failing test case input:
<>>><>><<><><<<<

Expected output:
23


Actual output:
39


Fixed submission (verdict: Accepted):
def main():

    S = input()
    left = [0]
    c = 0
    for i in range(len(S)):
        if S[i] == "<":
            c += 1
        else:
            c = 0
        left.append(c)
    right = [0]
    for i in range(len(S)-1, -1, -1):
        if S[i] == ">":
            c += 1
        else:
            c = 0
        right.append(c)
    right = right[::-1]

    
    
    

    ans = 0
    for i in range(len(left)):
        ans += max(left[i], right[i])
    return ans

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

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(input())
A = [0] * (len(S)+1)
imos = [0] * (len(S))
for i in range(len(S)):
    if S[i] == '>':
        imos[i] = 1
    else:
        imos[i] = -1000000
imos += [0]
for i in range(len(S), 0, -1):
    imos[i-1] = max(0, imos[i-1] + imos[i])

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


Failing test case input:
><<<<<<<><>>>>><

Expected output:
45


Actual output:
44


Fixed submission (verdict: Accepted):
S = list(input())
A = [0] * (len(S)+1)
imos = [0] * (len(S))
for i in range(len(S)):
    if S[i] == '>':
        imos[i] = 1
    else:
        imos[i] = -10000000
imos += [0]
for i in range(len(S), 0, -1):
    imos[i-1] = max(0, imos[i-1] + imos[i])
A[0] = imos[0]
for i in range(len(S)):
    if S[i] == '<':
        A[i+1] = max(imos[i+1], A[i]+1)
    else:
        A[i+1] = max(0, min(A[i]-1, imos[i+1]))
print(sum(A))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

total = 0
tmp_current = 0
tmp_high = 0
count_from_high = 1
flag_current = True 
for c in s:
    if c == '<':
        if not flag_current:
            count_from_high = 0
        total += tmp_current+1
        tmp_current += 1
        flag_current = True
    else:
        if flag_current:
            tmp_high = tmp_current
            flag_current = False
        else:
            if tmp_high > count_from_high:
                total += count_from_high
            else:
                total += count_from_high + 1
        tmp_current = 0
        count_from_high += 1
print(total)

Failing test case input:
<<>>><<<>><><><<

Expected output:
19


Actual output:
22


Fixed submission (verdict: Accepted):
s = input()

total = 0
tmp_current = 0
tmp_high = float('inf')
count_from_high = 1
flag_current = False 
for c in s:
    if c == '<':
        if not flag_current:
            count_from_high = 0
        total += tmp_current+1
        tmp_current += 1
        flag_current = True
    else:
        if flag_current:
            tmp_high = tmp_current
            flag_current = False
        else:
            if tmp_high > count_from_high:
                total += count_from_high
            else:
                total += count_from_high + 1
        tmp_current = 0
        count_from_high += 1
print(total)

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
><>><<><<<<><>><

Expected output:
21


Actual output:
32


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

        ans[i+1]=ans[i]+1
    

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
    
res = 0
for i in range(n+1):
    res+=ans[i]

print(res)
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
cnt = [[0, 0] for i in range(len(s))]
ans = 0
for i in range(len(s)):
    if s[i] == '<':
        cnt[i][0] += 1
    else:
        cnt[i][1] += 1
for i in range(1, len(s)):
    if cnt[i - 1][1] == 0:
        cnt[i][0] += cnt[i - 1][0]
    if cnt[len(s) - i][0] == 0:
        cnt[len(s) - i - 1][1] += cnt[len(s) - i][1]
    if s[i - 1] != s[i]:
        ans -= 1
for i in range(len(s)):
    ans += max(cnt[i])
print(ans)


Failing test case input:
<>>><>><<<><<><<

Expected output:
21


Actual output:
17


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
cnt = [[0, 0] for i in range(len(s) + 1)]
ans = 0
for i in range(len(s)):
    if s[i] == '<':
        cnt[i + 1][0] += 1
    else:
        cnt[i][1] += 1
for i in range(1, len(s) + 1):
    if cnt[i - 1][1] == 0:
        cnt[i][0] += cnt[i - 1][0]
    if cnt[len(s) - i + 1][0] == 0:
        cnt[len(s) - i][1] += cnt[len(s) - i + 1][1]
for i in range(len(s) + 1):
    ans += max(cnt[i])
print(ans)

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
>>>><<<<<<<><><>

Expected output:
40


Actual output:
1
3
6
10
11
13
16
20
25
31
38
38
39
39
40
40


Fixed submission (verdict: Accepted):
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)
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
ans=0
c=1
temp=0
for i in range(len(s)):
    if i==0:
        ans+=1
    else:
        if s[i]==">" and s[i]==s[i-1]:
            c+=1
            if temp>c:
                ans+=c-1
            else:
                ans+=c
        elif s[i]==">" and s[i]!=s[i-1]:
            temp=c
            c=1
        elif s[i]=="<" and s[i]==s[i-1]:
            c+=1
            ans+=c
        elif s[i]=="<" and s[i]!=s[i-1]:
            c=1
            ans+=1
    
print(ans)

Failing test case input:
<<>>>><<<<<>>><<

Expected output:
32


Actual output:
33


Fixed submission (verdict: Accepted):
s=input()
ans=0
c=1
temp=0
for i in range(len(s)):
    if i==0:
        ans+=1
    else:
        if s[i]==">" and s[i]==s[i-1]:
            c+=1
            if temp>=c:
                ans+=c-1
            else:
                ans+=c
        elif s[i]==">" and s[i]!=s[i-1]:
            temp=c
            c=1
        elif s[i]=="<" and s[i]==s[i-1]:
            c+=1
            ans+=c
        elif s[i]=="<" and s[i]!=s[i-1]:
            c=1
            tmp=0
            ans+=1
    
print(ans)

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input().strip()





20



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



Failing test case input:
<<>>><><><<><><<

Expected output:
16


Actual output:
17


Fixed submission (verdict: Accepted):
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)
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
<>><>>><<><<<<<>

Expected output:
27


Actual output:
28


Fixed submission (verdict: Accepted):
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)

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
<>><><><<><<>><<

Expected output:
15


Actual output:
15
[0, 2, 1, 0, 1, 0, 1, 0, 1, 2, 0, 1, 2, 1, 0, 1, 2]


Fixed submission (verdict: Accepted):
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))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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(1, N)[::-1]:
    if S[i] == '>':
        l[i] = max(l[i], l[i + 1] + 1)

print(sum(l))



Failing test case input:
><><<<>><<<<>>><

Expected output:
23


Actual output:
22


Fixed submission (verdict: Accepted):
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))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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))

Failing test case input:
<>>>><<<<><<<>><

Expected output:
28


Actual output:
[0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 1, 2, 3, 1, 0, 1]
28


Fixed submission (verdict: Accepted):
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))
Problem: p02873
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
left, right = [0,], []
a, b = 0, 0

for i in range(len(s)):
    a = a+1 if s[i] == '<' else 0
    left.append(a)
    b = b+1 if s[-1*i] == '>' else 0
    right.append(b)

right.append(0)
right.reverse()
ans = sum(max(x, y) for x, y in zip(left, right))
print(ans)

Failing test case input:
><<<<<><<<>>>>><

Expected output:
35


Actual output:
34


Fixed submission (verdict: Accepted):
s = input()
left, right = [0,], [0,]
a, b = 0, 0
for i in range(len(s)):
    a = a+1 if s[i] == '<' else 0
    left.append(a)
    b = b+1 if s[-1*(i+1)] == '>' else 0
    right.append(b)

right.reverse()
ans = sum(max(x, y) for x, y in zip(left, right))
print(ans)

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
<>><<<><<>><><><

Expected output:
16


Actual output:
3


Fixed submission (verdict: Accepted):
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)

Problem: p02873
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
s_Count = 0
b_Count = 0
ans = 0

for i in range(len(S)):
  if S[i] == "<" and i != len(S)-1:
    s_Count += 1
  else:
    b_Count += 1
    if i == len(S)-1 or S[i+1] == "<":
      max_sb = max(s_Count,b_Count)
      min_sb = min(s_Count,b_Count) - 1
      ans += max_sb * (max_sb+1) / 2 + min_sb * (min_sb+1) / 2
      s_Count = 0
      b_Count = 0
print(int(ans))

Failing test case input:
<>><><><<><<>><<

Expected output:
15


Actual output:
13


Fixed submission (verdict: Accepted):
S = input()
s_Count = 0
b_Count = 0
ans = 0

for i in range(len(S)):
  if S[i] == "<":
    s_Count += 1
    if i == len(S)-1:
      max_sb = max(s_Count,b_Count)
      min_sb = min(s_Count,b_Count) - 1
      ans += max_sb * (max_sb+1) / 2 + min_sb * (min_sb+1) / 2
      s_Count = 0
      b_Count = 0
  elif S[i] == ">":
    b_Count += 1
    if i == len(S)-1 or S[i+1] == "<":
      max_sb = max(s_Count,b_Count)
      min_sb = min(s_Count,b_Count) - 1
      ans += max_sb * (max_sb+1) / 2 + min_sb * (min_sb+1) / 2
      s_Count = 0
      b_Count = 0
print(int(ans))
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
n = len(S) + 1

A = [0 for _ in range(n)]
for i in range(n - 1):
    prev = A[i]
    if S[i] == "<":
        A[i + 1] = max(A[i + 1], prev + 1)

for i in range(n - 2, 0, -1):
    prev = A[i + 1]
    if S[i] == ">":
        A[i] = max(A[i], prev + 1)

print(sum(A))

Failing test case input:
><<<><<<<<>>>>><

Expected output:
33


Actual output:
32


Fixed submission (verdict: Accepted):
S = input()
n = len(S) + 1

A = [0 for _ in range(n)]
for i in range(n - 1):
    prev = A[i]
    if S[i] == "<":
        A[i + 1] = max(A[i + 1], prev + 1)

for i in range(n - 1):
    j = n - i - 2
    prev = A[j + 1]
    if S[j] == ">":
        A[j] = max(A[j], prev + 1)

print(sum(A))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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))

Failing test case input:
<<><<><<<>><>>><

Expected output:
20


Actual output:
14


Fixed submission (verdict: Accepted):
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))

Problem: p02873
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S = list(input())
N = len(S)


dammy1=[0]*(N+1)
A=0
for i in range(1,N+1):
    if S[i-1]=='<':
        A+=1
        dammy1[i]=A
    elif S[i-1]=='>':
        A=0
        dammy1[i]=A

dammy2=[0]*(N+1)
B=0
for i in range(1,N):
    if S[-i]=='>':
        B+=1
        dammy2[-(i+1)]=B
    elif S[i]=='<':
        B=0
        dammy2[-(i+1)]=B




out=[0]*(N+1)
for i in range(N+1):
    out[i] = max(dammy1[i], dammy2[i])


print(sum(out))

Failing test case input:
><>><<><<<<<>>><

Expected output:
26


Actual output:
25


Fixed submission (verdict: Accepted):
S = list(input())
N = len(S)


dammy1=[0]*(N+1)
A=0
for i in range(1,N+1):
    if S[i-1]=='<':
        A+=1
        dammy1[i]=A
    elif S[i-1]=='>':
        A=0
        dammy1[i]=A

dammy2=[0]*(N+1)
B=0
for i in range(1,N+1):
    if S[-i]=='>':
        B+=1
        dammy2[-(i+1)]=B
    elif S[-i]=='<':
        B=0
        dammy2[-(i+1)]=B




out=[0]*(N+1)
for i in range(N+1):
    out[i] = max(dammy1[i], dammy2[i])


print(sum(out))
Problem: p02873
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = input()
ans = 0
flag = 0 
x = s[0]
r = 0 
l = 0 

if x==">":
    flag = 1
    l += 1
else:
    r += 1

for i in range(1,len(s)):
    if s[i]==x:
        if flag==1:
            l += 1
        else:
            r += 1
    else:
        if flag==1:
            ans += sum(range(max(r,l)+1)) + sum(range(min(r,l)))
            l = 0
            r = 1
            x = s[i]
            flag = 0
        else:
            x = s[i]
            l += 1
            flag = 1
    print(i,r,l,ans)
ans += sum(range(max(r,l)+1)) + sum(range(min(r,l)))
print(ans)


Failing test case input:
<<>><<><<<<>>>><

Expected output:
24


Actual output:
1 2 0 0
2 2 1 0
3 2 2 0
4 1 0 4
5 2 0 4
6 2 1 4
7 1 0 7
8 2 0 7
9 3 0 7
10 4 0 7
11 4 1 7
12 4 2 7
13 4 3 7
14 4 4 7
15 1 0 23
24


Fixed submission (verdict: Accepted):
s = input()
ans = 0
flag = 0 
x = s[0]
r = 0 
l = 0 

if x==">":
    flag = 1
    l += 1
else:
    r += 1

for i in range(1,len(s)):
    if s[i]==x:
        if flag==1:
            l += 1
        else:
            r += 1
    else:
        if flag==1:
            ans += sum(range(max(r,l)+1)) + sum(range(min(r,l)))
            l = 0
            r = 1
            x = s[i]
            flag = 0
        else:
            x = s[i]
            l += 1
            flag = 1
ans += sum(range(max(r,l)+1)) + sum(range(min(r,l)))
print(ans)

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

l = len(S)
x = [0]*(l+3)
y = [0]*(l+3)
for i in range(l):
    if S[i] == "<":
        x[i+1] = x[i]+1
for i in range(l):
    if S[i] == ">":
        y[l-i+1] = y[l-i+2]+1


res = 0
for i in range(l+1):
    res += max(x[i], y[i+2])
print(res)

Failing test case input:
<>><<<<<<><<>>>>

Expected output:
35


Actual output:
37


Fixed submission (verdict: Accepted):
S = input()

l = len(S)
x = [0]*(l+1)
y = [0]*(l+1)
for i in range(l):
    if S[i] == "<":
        x[i+1] = x[i]+1
for i in range(l):
    if S[l-i-1] == ">":
        y[l-i-1] = y[l-i]+1

res = 0
for a, b in zip(x, y):
    res += max(a, b)

print(res)

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=list(input())

s=0
f=0
g=0
h=0
for i in range(len(S)):
    if S[i]==">":
        g=0
        f+=1
        if f!=1:
            if h>=f:
                s+=f-1
            else:
                s+=f-1+h
        
    else:
        f=0
        g+=1
        s+=g
        h=g

print(s)


Failing test case input:
<<><<>>><><<>><<

Expected output:
18


Actual output:
19


Fixed submission (verdict: Accepted):
S=list(input())

s=0
f=0
g=0
h=0
for i in range(len(S)):
    if S[i]==">":
        g=0
        f+=1
        if h>=f:
            s+=f-1
        else:
            s+=f
        
    else:
        f=0
        g+=1
        s+=g
        h=g

print(s)