ZhenlongDai/ACPR huggingface dataset:
Problem: p02873
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):


def main():
    
    s = '<>>><<><<<<<>>><'
    n_list = [0] * (len(s)+1)
    

    for i in range(0, len(s)):
        if s[i] == '<':
            n_list[i+1] = n_list[i]+1
        else: 
            j = i 
            k = 1                          
            for j in range(i, 0, -1):
                if s[j] == '<':
                    n_list[j+1] = max(n_list[j], n_list[j+2])+1
                    break
                n_list[j] = k                
                j-=1
                k+=1
        if s[0] == '>':
            n_list[0] = n_list[1]+1
        print('i={} {}'.format(i, n_list))    

    print(n_list)
    print(int(sum(n_list)))


if __name__ == "__main__":
    main()





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

Expected output:
16


Actual output:
i=0 [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
i=1 [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
i=2 [0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
i=3 [0, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
i=4 [0, 3, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
i=5 [0, 3, 2, 1, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
i=6 [0, 3, 2, 1, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
i=7 [0, 3, 2, 1, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
i=8 [0, 3, 2, 1, 0, 1, 2, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0]
i=9 [0, 3, 2, 1, 0, 1, 2, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0]
i=10 [0, 3, 2, 1, 0, 1, 2, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0]
i=11 [0, 3, 2, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0]
i=12 [0, 3, 2, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0]
i=13 [0, 3, 2, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5, 1, 0, 0, 0]
i=14 [0, 3, 2, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5, 2, 1, 0, 0]
i=15 [0, 3, 2, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5, 2, 1, 0, 1]
[0, 3, 2, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5, 2, 1, 0, 1]
28


Fixed submission (verdict: Accepted):



def main():
    s = input()
    
    
    n_list = [0] * (len(s)+1)
    

    for i in range(1, len(s)):
        if s[i-1] == '<':
            n_list[i] = n_list[i-1]+1
        else: 
            if s[i] == '>':
                continue
            
            k = 1                          
            for j in range(i, 1, -1):
                if s[j-1] == '<':
                    n_list[j] = max(n_list[j-1], n_list[j+1])+1
                    break
                n_list[j-1] = k
                k+=1
    
    if s[-1] == '<':
        n_list[-1] = n_list[-2]+1
    elif s[-1] == '>':
        
        k = 1                     
        for j in range(len(s), 1, -1):
            if s[j-1] == '<':
                n_list[j] = max(n_list[j-1], n_list[j+1])+1
                break
            n_list[j-1] = k
            k+=1
    if s[0] == '>':
        n_list[0] = n_list[1]+1
            
        
 
    
    print(int(sum(n_list)))


if __name__ == "__main__":
    
    main()
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)
print(ans)


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

Expected output:
28


Actual output:
26


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()
nums = [0] * (len(S)+1)
pos = 0
count = 0
pre_count = 0
now = '>'
for (i, s) in enumerate(S):
  if s != now:
    if s == '<':
      nums[pos] = max(pre_count, count)
      while pos != i:
        pos += 1
        count -= 1
        nums[pos] = count
    else:
      pos = i
      pre_count = count+1
      count = 1
    now = s
  else:
    count += 1
    if s == '<':
      nums[i] = count
if now == '<':
  nums[i+1] = count+1

print(sum(nums))

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

Expected output:
19


Actual output:
18


Fixed submission (verdict: Accepted):
S = input()
nums = [0] * (len(S)+1)
pos = 0
count = 0
pre_count = 0
now = '>'
for (i, s) in enumerate(S):
  if s != now:
    if s == '<':
      nums[pos] = max(pre_count, count)
      while pos != i:
        pos += 1
        count -= 1
        nums[pos] = count
    else:
      pos = i
      pre_count = count+1
      count = 1
    now = s
  else:
    count += 1
    if s == '<':
      nums[i] = count
if now == '<':
  nums[i+1] = count+1

if s == '>':
  nums[pos] = max(pre_count, count)
  while pos != i+1:
    pos += 1
    count -= 1
    nums[pos] = count

print(sum(nums))

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

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

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

Expected output:
26


Actual output:
24


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

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

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

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

Expected output:
36


Actual output:
32


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

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

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

s = str(input())

s_length = len(s)

answer = 0
cnt = 0
t = 0
_t = 0
for i in range(s_length):
  if s[i] == '<':
    t += 1
    cnt = 0
    answer += t
  else:
    if t == 0:
      if _t <= cnt:
        t = 0
        cnt += 1
        answer += cnt 
      else:
        t = 0
        cnt += 1
        answer += cnt - 1
    else:
      _t = t
      t = 0
      answer += cnt * 1
      cnt += 1
      

print(answer)

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

Expected output:
24


Actual output:
26


Fixed submission (verdict: Accepted):
s = str(input())
 
s_length = len(s)
 
answer = 0
cnt = 0
t = 0
_t = 0
for i in range(s_length):
  if s[i] == '<':
    t += 1
    cnt = 0
    answer += t
  else:
    if t == 0:
      if _t <= cnt:
        t = 0
        cnt += 1
        answer += cnt 
      else:
        t = 0
        cnt += 1
        answer += cnt - 1
    else:
      _t = t
      t = 0
      answer += cnt * 1
      cnt += 1
      
print(answer)
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) + 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)):
    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]
for i in range(len(s) + 1):
    ans += max(cnt[i])
print(ans)


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

Expected output:
28


Actual output:
24


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

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

if __name__ == "__main__":
    main()


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

Expected output:
18


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


Fixed submission (verdict: Accepted):

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

if __name__ == "__main__":
    main()
Problem: p02873
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = list(input())
n = len(s)
s.append('<')
mini = 0
maxi = 0
p = 0

for i in range(n):
    if s[i] == '<':
        mini += 1
    else:
        maxi += 1
        if s[i+1] == '<':
            p += (1 + max(mini,maxi)) * max(mini,maxi) 
            mini = 0
            maxi = 0

print(p)

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

Expected output:
23


Actual output:
40


Fixed submission (verdict: Accepted):
s = list(input())
n = len(s)
s.append('<')
mini = 0
maxi = 0
p = 0

for i in range(n):
    if s[i] == '<':
        mini += 1
    else:
        maxi += 1
        if s[i+1] == '<':
            m = max(mini,maxi)
            p += (1 + m) * m 
            m = min(mini,maxi) - 1
            p += (1 + m) * m 
            mini = 0
            maxi = 0

if mini != 0:
    print(p + ((1+mini) * mini 
else:
    print(p)

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]=a[i]+1
for i in range(N-1,-1,-1):
    if S[i] == '>':
        a[i]=a[i+1]+1
print(sum(a))

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

Expected output:
17


Actual output:
15


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

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


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

Failing test case input:
>><

Expected output:
4


Actual output:
2


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


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

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

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

Expected output:
35


Actual output:
30


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):
def calc(n):
    return n * (n+1) / 2

S = list(input())

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

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

l.append((prev, series))

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

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

print(int(res))


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

Expected output:
30


Actual output:
32


Fixed submission (verdict: Accepted):
def calc(n):
    return n * (n+1) / 2

S = list(input())

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

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

l.append((prev, series))

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

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

print(int(res))

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


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

Expected output:
40


Actual output:
36


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

l, r = min(l, r), max(l, r)
ans += l * (l - 1) 
print(ans)


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

Expected output:
28


Actual output:
2


Fixed submission (verdict: Accepted):
S = input()
n = len(S)
S = S + " "
ans = 0
l = 0
r = 0
temp = 0

if S[0] == '<':
    temp = 0
else:
    for i in range(n):
        if S[i] == '>' and S[i + 1] == ('<'):
            temp = i+1
            break
        if i == n - 1:
            print((n + 1) * n 
            exit()
ans += (temp) * (temp + 1) 
i = max(temp, 0)

while(i < n):
    while (i < n and S[i] == '<'):
        l += 1
        i += 1
    while (i < n and S[i] == '>'):
        r += 1
        i += 1
    l, r = min(l, r), max(l, r)
    ans += l * (l - 1) 
    l = 0
    r = 0

l, r = min(l, r), max(l, r)
ans += l * (l - 1) 
print(ans)

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

sl=len(s)+1
l=[0]*sl

for i in range(sl-1):
  if s[i]=="<":
    l[i+1]=l[i]+1
    
for i in range(sl-2,-1,-1):
  if s[i]==">":
    l[i]=max(l[i+1], l[i])
    
print(sum(l))
  
  

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

Expected output:
26


Actual output:
17


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

sl=len(s)+1
l=[0]*sl

for i in range(sl-1):
  if s[i]=="<":
    l[i+1]=l[i]+1
    
for i in range(sl-2,-1,-1):
  if s[i]==">":
    l[i]=max(l[i+1]+1, l[i])
    
print(sum(l))

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

big = [0]*(len(S)+1)
for i in range(len(S)):
  if S[i] == "<":
    big[i+1] = big[i] +1
  else:
    big[i+1] = 0
  
small = [0]*(len(S)+1)
for i in range(len(S)-1, 0, -1):
  if S[i] == ">":
    small[i] = small[i+1] + 1
  else:
    small[i] = 0
    
for b, s in zip(big, small):
  ans += max(b, s)

print(ans)

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

Expected output:
36


Actual output:
32


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

big = [0]*(len(S)+1)
for i in range(len(S)):
  if S[i] == "<":
    big[i+1] = big[i] +1
  else:
    big[i+1] = 0
  
small = [0]*(len(S)+1)
for i in range(len(S)-1, -1, -1):
  if S[i] == ">":
    small[i] = small[i+1] + 1
  else:
    small[i] = 0
    
for b, s in zip(big, small):
  ans += max(b, s)

print(ans)
Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
w1 = input()
length = len(w1)
num_list = [-1]*(length+1)
c1 = 0
c2 = 0
for i in range(length):
    if i==0 and w1[i] == "<":
        num_list[0] = 0
    if i==(length-1) and w1[i] == ">":
        num_list[length] = 0
    if not i==length-1:
        if w1[i] == ">" and w1[i+1] =="<":
            num_list[i+1] = 0

    if(w1[i] == "<"):
        num_list[i+1] = num_list[i] + 1

for i in range(length-1,-1,-1):
    if (w1[i] == ">"):
        if(num_list[i] < num_list[i+1] + 1):
            num_list[i] = num_list[i+1] + 1

allsum = 0
print(num_list)
print(sum(num_list))





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

Expected output:
28


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


Fixed submission (verdict: Accepted):
w1 = input()
length = len(w1)
num_list = [-1]*(length+1)
c1 = 0
c2 = 0
for i in range(length):
    if i==0 and w1[i] == "<":
        num_list[0] = 0
    if i==(length-1) and w1[i] == ">":
        num_list[length] = 0
    if not i==length-1:
        if w1[i] == ">" and w1[i+1] =="<":
            num_list[i+1] = 0

    if(w1[i] == "<"):
        num_list[i+1] = num_list[i] + 1

for i in range(length-1,-1,-1):
    if (w1[i] == ">"):
        if(num_list[i] < num_list[i+1] + 1):
            num_list[i] = num_list[i+1] + 1


print(sum(num_list))

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)

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

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

Expected output:
34


Actual output:
[0, 1, 2, 3, 4, 5, 6, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]
34
[0, 1, 2, 3, 4, 5, 6, 0, 3, 2, 1, 0, 3, 2, 1, 0, 1]


Fixed submission (verdict: Accepted):
S=input()
N=len(S)+1
l=[0]*N
for i in range(N-1):
    if S[i]=="<":
        l[i+1]=l[i]+1
for i in range(N-2,-1,-1):
    if S[i]==">":
        l[i]=max(l[i+1]+1,l[i])
print(sum(l))
Problem: p02873
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = input()
n = len(s)
ans = 0
l = 0
ll = [0] * (n + 1)
r = 0
rl = [0] * (n + 1)
for i in range(n):
    if s[i] == '<':
        l += 1
        ll[i+1] = l
    else:
        l = 0
    if s[-i] == '>':
        r += 1
        rl[-i-1] = r
    else:
        r = 0
for i in range(n + 1):
    ans += max(rl[i], ll[i])
print(ans)

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

Expected output:
18


Actual output:
17


Fixed submission (verdict: Accepted):
s = input()
n = len(s)
ans = 0
l = 0
ll = [0] * (n + 1)
r = 0
rl = [0] * (n + 1)
for i in range(n):
    if s[i] == '<':
        l += 1
        ll[i+1] = l
    else:
        l = 0
    if s[n-1-i] == '>':
        r += 1
        rl[n-i-1] = r
    else:
        r = 0
for i in range(n + 1):
    ans += max(rl[i], ll[i])
print(ans)

Problem: p02873
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = str(input())
l = []

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

cnt = 0
ans = 0
prev = 0

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


for i,sign in enumerate(l):
    if sign[0]=='>':
        if len(l[i-1]) >= len(l[i]):
            ans += orthodox(len(sign)-1)
        else:
            ans += orthodox(len(sign))
    elif sign[0]=='<':
        if i!=len(l)-1:
            if len(l[i]) < len(l[i+1]):
                ans += orthodox(len(sign)-1)
            else:
                ans += orthodox(len(sign))
        else:
            ans += orthodox(len(sign))

print(ans)

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

Expected output:
33


Actual output:
32


Fixed submission (verdict: Accepted):

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


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

left = 0
right = 0
ans = 0

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

print(ans)
Problem: p02873
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
s=input()
l=len(s)
ans=0
for i in range(l-1):
    if s[i]=="<" and s[i+1]==">":
        left=1
        right=1
        for j in range(i):
            if s[i-j-1]=="<":
                left+=1
            else:
                break
        for j in range(l-i-2):
            if s[i+j+2]==">":
                right+=1
            else:
                break
        p=max(left,right)
        q=min(left,right)
        for j in range(p):
            ans+=(j+1)
        for j in range(q-1):
            ans+=(j+1)
if s[0]==">":
    ans+=1
    for i in range(1,l):
        if s[i]==">":
            ans+=(i+1)
        else:
            break
if s[-1]=="<":
    ans+=1
    for i in range(2,l+1,-1):
        if s[-i]=="<":
            ans+=i
        else:
            break

print(ans)

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

Expected output:
26


Actual output:
21


Fixed submission (verdict: Accepted):
s=list(input())
l=len(s)
ans=0

if len(set(s))==1:
    for i in range(1,l+1):
        ans+=i
    print(ans)
    exit()

for i in range(l-1):
    if s[i]=="<" and s[i+1]==">":
        left=1
        right=1
        for j in range(i):
            if s[i-j-1]=="<":
                left+=1
            else:
                break
        for j in range(l-i-2):
            if s[i+j+2]==">":
                right+=1
            else:
                break
        p=max(left,right)
        q=min(left,right)
        for j in range(p):
            ans+=(j+1)
        for j in range(q-1):
            ans+=(j+1)
if s[0]==">":
    ans+=1
    for i in range(1,l):
        if s[i]==">":
            ans+=(i+1)
        else:
            break
if s[-1]=="<":
    ans+=1
    for i in range(2,l+1):
        if s[-i]=="<":
            ans+=i
        else:
            break
print(ans)

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

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

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

Expected output:
16


Actual output:
15


Fixed submission (verdict: Accepted):

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

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

Expected output:
24


Actual output:
23


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):
import sys
input = sys.stdin.readline
 
s = str(input())
 
s_length = len(s)
 
answer = 0
cnt = 0
t = 0
_t = 0
for i in range(s_length):
  if s[i] == '<':
    t += 1
    cnt = 0
    answer += t
  else:
    if t == 0:
      if _t <= cnt:
        t = 0
        cnt += 1
        answer += cnt 
      else:
        t = 0
        cnt += 1
        answer += cnt - 1
    else:
      _t = t
      t = 0
      answer += cnt * 1
      cnt += 1
      
print(answer)

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

Expected output:
20


Actual output:
21


Fixed submission (verdict: Accepted):
s = str(input())
 
s_length = len(s)
 
answer = 0
cnt = 0
t = 0
_t = 0
for i in range(s_length):
  if s[i] == '<':
    t += 1
    cnt = 0
    answer += t
  else:
    if t == 0:
      if _t <= cnt:
        t = 0
        cnt += 1
        answer += cnt 
      else:
        t = 0
        cnt += 1
        answer += cnt - 1
    else:
      _t = t
      t = 0
      answer += cnt * 1
      cnt += 1
      
print(answer)

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

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

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

Expected output:
16


Actual output:
21


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

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

Problem: p02873
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S=input()
N = len(S) + 1
ary = [0] * N
for i in range(N-1):
    if S[i] == "<":
        ary[i+1] = ary[i] + 1

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

print(sum(ary))

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

Expected output:
25


Actual output:
24


Fixed submission (verdict: Accepted):
S=input()
N = len(S) + 1
ary = [0] * N
for i in range(N-1):
    if S[i] == "<":
        ary[i+1] = ary[i] + 1

for i in range(N-2,-1,-1):
    if S[i] == ">":
        ary[i] = max(ary[i], ary[i+1] + 1)

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

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

print(sum(ans))


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

Expected output:
26


Actual output:
14


Fixed submission (verdict: Accepted):

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

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

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

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

Expected output:
22


Actual output:
<
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
<
[0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>
[0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>
[0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>
[0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
<
[0, 1, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>
[0, 1, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
<
[0, 1, 2, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
<
[0, 1, 2, 0, 0, 0, 1, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0]
<
[0, 1, 2, 0, 0, 0, 1, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0]
<
[0, 1, 2, 0, 0, 0, 1, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0]
>
[0, 1, 2, 0, 0, 0, 1, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0]
<
[0, 1, 2, 0, 0, 0, 1, 0, 1, 2, 3, 4, 0, 1, 0, 0, 0]
>
[0, 1, 2, 0, 0, 0, 1, 0, 1, 2, 3, 4, 0, 1, 0, 0, 0]
>
[0, 1, 2, 0, 0, 0, 1, 0, 1, 2, 3, 4, 0, 1, 0, 0, 0]
<
[0, 1, 2, 0, 0, 0, 1, 0, 1, 2, 3, 4, 0, 1, 0, 0, 1]

<
[1, 0, 0, 1, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
>
[1, 0, 1, 1, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
>
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
<
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
>
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
<
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
<
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
<
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
<
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
>
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
<
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0]
>
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 1, 0, 2, 1, 0]
>
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0]
>
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0]
<
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0]
<
[1, 0, 1, 2, 0, 4, 3, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0]

21


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.4.3), verdict: Wrong Answer):
S = input()
N = len(S)+1
a = [0] * N
for i in range(N-1):
	if S[i] == '<':
		a[i+1] = a[i]+1
for i in range(N-2, -1, -1):
  if S[i] == '>':
    a[i] = max(a[i+1]+1,a[i])
print(a)
print(sum(a))

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

Expected output:
20


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


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

print(sum(a))

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

import sys
s = sys.stdin.readline().rstrip()
n = len(s)
L = [0 for _ in range(n+1)]

for i in range(n):
    if s[i] == '<':
        L[i+1] = L[i] +1



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



print(sum(L))

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

Expected output:
25


Actual output:
24


Fixed submission (verdict: Accepted):

import sys
s = sys.stdin.readline().rstrip()
n = len(s)
L = [0 for _ in range(n+1)]

for i in range(n):
    if s[i] == '<':
        L[i+1] = L[i] +1



for i in range(n-1,-1,-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):
import sys
s = tuple(map(str, input().split("><")))
n = len(s)
ans = 0
def calc(x, y):
    return (x*(x-1) + y*(y-1))/2 + max(x, y)
if n == 1:
    a = s[0].count("<")
    b = s[0].count(">")
    sys.exit()
for i in range(n):
    if i == 0:
        a = s[i].count("<")
        b = s[i].count(">") + 1
    elif i == n - 1:
        a = s[i].count("<") + 1
        b = s[i].count(">")
    else:
        a = s[i].count("<") + 1
        b = s[i].count(">") + 1
    ans += calc(a, b)

print(int(ans))


Failing test case input:
<<>

Expected output:
3


Actual output:

Fixed submission (verdict: Accepted):
import sys
s = tuple(map(str, input().split("><")))
n = len(s)
ans = 0
def calc(x, y):
    return (x*(x-1) + y*(y-1))/2 + max(x, y)
if n == 1:
    a = s[0].count("<")
    b = s[0].count(">")
    print(int(calc(a, b)))
    sys.exit()
for i in range(n):
    if i == 0:
        a = s[i].count("<")
        b = s[i].count(">") + 1
    elif i == n - 1:
        a = s[i].count("<") + 1
        b = s[i].count(">")
    else:
        a = s[i].count("<") + 1
        b = s[i].count(">") + 1
    ans += calc(a, b)

print(int(ans))

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



a = [0]*(n+2)


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


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

print(sum(a))

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

Expected output:
26


Actual output:
25


Fixed submission (verdict: Accepted):
s = list(input())
n = len(s)



a = [0]*(n+2)


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


for i in range(n-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 = 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:
37


Actual output:
36


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

print(sum(a))

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

Expected output:
19


Actual output:
><<><>>><<><<<><><
19


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

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

Expected output:
25


Actual output:
24


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 (PyPy3 (7.3.0), verdict: Wrong Answer):
S = list(input())
 
left = [0]*(len(S)+1)
 
right = [0]*(len(S)+1)
 
for i in range(len(S)):
    if S[i] == '<':
        left[i+1] += 1+left[i]
 
for i in range(len(S)-1,-1,-1):
    if S[i] == '>':
        right[i] = right[i+1]+1
 
ans = [0]*(len(S)+1)
for i in range(len(S)+1):
    ans[i] = max(left[i],right[i])
print(sum(ans)+1) 

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

Expected output:
29


Actual output:
30


Fixed submission (verdict: Accepted):
S = list(input())
 
left = [0]*(len(S)+1)
 
right = [0]*(len(S)+1)
 
for i in range(len(S)):
    if S[i] == '<':
        left[i+1] += 1+left[i]
 
for i in range(len(S)-1,-1,-1):
    if S[i] == '>':
        right[i] = right[i+1]+1
 
ans = [0]*(len(S)+1)
for i in range(len(S)+1):
    ans[i] = max(left[i],right[i])
print(sum(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)



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

Expected output:
20


Actual output:

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 (PyPy3 (2.4.0), verdict: Wrong Answer):
S = str(input())
N = len(S) + 1

ans = 0

con = 0
mae = 10 ** 6
x = "a"
for i in range(N-1):
  if i == 0:
    con = 1
  else:
    if S[i] == x:
      con += 1
    else:
      ans += (1/2) * con * (con - 1) 
      if S[i] == "<":
        if mae < con:
          ans += con
        else:
          if mae != 10 ** 6:
            ans += mae
      
      x = S[i]
      mae = con
      con = 1
  

ans += (1/2) * con * (con + 1) 
if con == 1:
  if S[i] == ">":
    ans += mae

print(int(ans))

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

Expected output:
28


Actual output:
26


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

ans = 0

con = 0
x = S[0]
i = 0
while x != "<":
  con += 1
  x = S[i]
  if x == ">":
    i += 1
  if i == N-1:
    x = "<"
ans += con * (con - 1) / 2


if i == N-1:
  ans += con
  print(int(ans))
  quit()
  

mae = 0
con = 1
x = "<"
i += 1

while i < N - 1:
  if S[i] == x:
    
    con += 1
  else:
    ans += con * (con-1)/2
    if S[i] == ">":
      mae = con
    else:
      ans += max(con, mae)
      mae = 0
    con = 1
    x = S[i]
    
  i += 1

ans += con * (con-1)/2 

ans += max(con, mae)

print(int(ans))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
ans = 0
if s[-1] != '<':
    s += '<'
else:
    ans += 1
n = len(s)
f = lambda x: x * (x + 1) 

l, k = 0, 0
for i in range(n):
    if s[i:i+2] == '><':
        k += 1
        l += 1
        ans += f(k) + f(l - k) - min(k, l-k)
        k, l = 0, 0
    else:
        l += 1
        if s[i] == '>': k += 1

print(ans)

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

Expected output:
18


Actual output:
41


Fixed submission (verdict: Accepted):
s = input()
s += '<' if s[-1] == '>' else '>'
n = len(s)
f = lambda x: x * (x + 1) 

ans = 0
a, k = 1, 0
for i in range(n-1):
    if s[i] == s[i+1]:
        a += 1
        ans += a
    else:
        if s[i] == '<':
            k = a
        else:
            ans -= min(a, k)
        a = 1
        ans += a
print(ans)
Problem: p02873
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def compute_score(sub):
    max_i = max(sub)
    min_i = min(sub)
    score = max_i * (max_i + 1) * (1 /2) + min_i * (min_i - 1) * (1/2)
    return score

S = input()
sub = [0, 0]
ans = 0
flag = False
for s in S:
    if s == '<' and flag:
        ans += compute_score(sub)
        sub = [0, 0]
        flag = False
    if s == '>':
        flag = True
    if s == '<':
        sub[0] += 1
    else:
        sub[1] += 1
ans += compute_score(sub)
print(ans)

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

Expected output:
34


Actual output:
34.0


Fixed submission (verdict: Accepted):
def compute_score(sub):
    max_i = max(sub)
    min_i = min(sub)
    score = max_i * (max_i + 1) * (1 /2) + min_i * (min_i - 1) * (1/2)
    return score

S = input()
sub = [0, 0]
ans = 0
flag = False
for s in S:
    if s == '<' and flag:
        ans += compute_score(sub)
        sub = [0, 0]
        flag = False
    if s == '>':
        flag = True
    if s == '<':
        sub[0] += 1
    else:
        sub[1] += 1
ans += compute_score(sub)
print(int(ans))
Problem: p03210
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X=int(input())
if X==7 or X==5 or X==3:
  print("Yes")
else:
  print("No")

Failing test case input:
-64

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
X=int(input())
if X==7 or X==5 or X==3:
  print("YES")
else:
  print("NO")

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x=int(input())
print('Yes' if x in (3,5,7) else 'No')


Failing test case input:
-154

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
x=int(input())
print('YES' if x in (3,5,7) else 'NO')

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
print("Yes" if a == 3 or a == 5 or a == 7 else "No")

Failing test case input:
959

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a = int(input())
print("YES" if a == 3 or a == 5 or a == 7 else "NO")

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

print('YES' if input() in ['3','5','7'] else 'No')

Failing test case input:
959

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):

print('YES' if input() in ['3','5','7'] else 'NO')

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = int(input())

if x == 3 or 5 or 7:
    print("YES")
else:
    print("NO")

Failing test case input:
669

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
x = int(input())

if x == 3 or x == 5 or x == 7:
    print("YES")
else:
    print("NO")

Problem: p03210
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X = int(input())

if X == 7 or X == 5 or X == 3:
    print('Yes')
else:
    print('No')

Failing test case input:
669

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
X = int(input())

if X == 7 or X == 5 or X == 3:
    print('YES')
else:
    print('NO')

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x=int(input())
if x==3 or x==5 or x==7:
  print('Yes')
else:
  print('No')

Failing test case input:
-154

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
x=int(input())
if x==3 or x==5 or x==7:
  print('YES')
else:
  print('NO')

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x=int(input())

if x in [7,5,3]:
    print('Yes')
else:
    print('No')


Failing test case input:
-99

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
x=int(input())

if x in [7,5,3]:
    print('YES')
else:
    print('NO')

Problem: p03210
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
X = int(input())

if '3' or '5' or '7' in X:
  print('YES')
else:
  print('NO')

Failing test case input:
469

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
X = int(input())

if X == 3 or X == 5 or X == 7:
  print('YES')
else:
  print('NO')
Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = input()
if x in "753":
  print('Yes')
else:
  print('No')

Failing test case input:
-64

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
x = input()
if x in "753":
  print("YES")
else:
  print("NO")

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = int(input())
print("YES" if x == 3 or 5 or 7 else "NO" )

Failing test case input:
-99

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
x = int(input())
print("YES" if x == 3 or x == 5 or x == 7 else "NO" )

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X = input()

if X == 3 or X == 5 or X == 7:
    print("Yes")
else:
    print("No")

Failing test case input:
959

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
X = int(input())

if X == 3 or X == 5 or X == 7:
    print("YES")
else:
    print("NO")

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

X = int(input())


if X in [7, 5, 3]:
    print("Yes")
else:
    print("No")

Failing test case input:
-99

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):

X = int(input())


if X in [7, 5, 3]:
    print("YES")
else:
    print("NO")

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
i=int(input())
if(i==7 or i==5 or i==3):
    print("YES")
else:
    print("No")

Failing test case input:
1271

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
i=int(input())
if(i==7 or i==5 or i==3):
    print("YES")
else:
    print("NO")

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X=int(input())
if X==3 or X==5 or X==7:
  print('YES')
else:
  print('No')

Failing test case input:
469

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
X=int(input())
if X==3 or X==5 or X==7:
  print('YES')
else:
  print('NO')

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = int(input())
if x == 3 or 5 or 7:
  print('YES')
else:
  print('NO')

Failing test case input:
-99

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
x = int(input())
if x == 3 or x == 5 or x == 7:
  print('YES')
else:
  print('NO')

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = int(input())
if x ==3 or x==5 or x==7:
    print("Yes")
else:
    print("No")

Failing test case input:
469

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
x = int(input())
if x ==3 or x==5 or x==7:
    print("YES")
else:
    print("NO")

Problem: p03210
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X=int(input())
if X==3 or 5 or 7:
  print("YES")
else:
  print("NO")

Failing test case input:
469

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
X=int(input())
if X==3 or X==5 or X==7:
  print("YES")
else:
  print("NO")