ZhenlongDai/ACPR huggingface dataset:
Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
clist = []
for i in range(1,N):
  clist = clist + [A.count(i)]
for j in clist:
  print(j)

Failing test case input:
7
1 2 2 3 6 2

Expected output:
1
3
1
0
0
1
0


Actual output:
1
3
1
0
0
1


Fixed submission (verdict: Accepted):
import collections
N = int(input())
A = list(map(int, input().split()))
clist = collections.Counter(A)
for i in range(1,N + 1):
  print(clist[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

lis = [0]*len(a)

for i in range(n-1):
  for j in range(len(a)):
    if a[j] == i+1:
      lis[i] += 1

print(*lis, sep='\n')

Failing test case input:
10
1 1 1 2 1 2 1 1 2

Expected output:
6
3
0
0
0
0
0
0
0
0


Actual output:
6
3
0
0
0
0
0
0
0


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int,input().split()))

lis = [0] * n
for i in A:
  lis[i-1] += 1

for j in range(len(lis)):
  print(lis[j])

Problem: p02707
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
size = int(input())
li = list(map(int,input().split()))
ans = [0]*size
for i in li:
    if i not in ans:
        ans[i-1] = 1
    else:
        ans[i-1] += 1
for i in ans:
    print(i)

Failing test case input:
10
1 1 1 4 1 2 1 1 2

Expected output:
6
2
0
1
0
0
0
0
0
0


Actual output:
4
1
0
1
0
0
0
0
0
0


Fixed submission (verdict: Accepted):
size = int(input())
li = list(map(int,input().split()))
from collections import Counter
c1 = Counter(li)
ans2 = [0] * size
for i,j in c1.items():
    ans2[i-1] = j
for i in ans2:
    print(i)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N-1):
        print(A.count(i+1))
resolve()

Failing test case input:
5
1 2 4 5

Expected output:
1
1
0
1
1


Actual output:
1
1
0
1


Fixed submission (verdict: Accepted):
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = [0]*N
    for i in A:
        ans[i-1] += 1
    for j in ans:
        print(j)
resolve()

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
sub = []
for i in range(0, n):
    sub.append(0)
for j in a :
    sub[j - 1] += 1
print(sub)

Failing test case input:
5
1 2 4 3

Expected output:
1
1
1
1
0


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


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
sub = []
for i in range(0, n):
    sub.append(0)
for j in a :
    sub[j - 1] += 1
for i in sub:
    print(i)
Problem: p02707
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import collections
n = int(input())
a = list(map(int, input().split()))

ans = [0]*n
a.sort()
a = collections.deque(a)
counter = 0
tem = a[0]
for i in range(1, n+1):
    while i == tem and len(a) != 0:
        tem = a.popleft()
        if i != tem: 
            break
        counter += 1    
    print(counter)
    counter = 0
    


Failing test case input:
7
2 2 6 2 4 7

Expected output:
0
3
0
1
0
1
1


Actual output:
0
3
0
0
0
0
0


Fixed submission (verdict: Accepted):
import collections
n = int(input())
a = list(map(int, input().split()))

a.sort()
a = collections.deque(a)
counter = 0
for i in range(1, n+1):
    while len(a) != 0:
        if i != a[0]: 
            break
        counter += 1
        a.popleft()    
    print(counter)
    counter = 0

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))


A.sort()
A.append(N + 1)
ans = [0] * (N+1)
count = [0, 0]

for i in range(N):
    if count[0] == A[i]:
        count[1] += 1
    else:
        ans[count[0]] = count[1]
        count[0] = A[i]
        count[1] = 1

print(ans[1:N+1])

Failing test case input:
5
4 2 4 2

Expected output:
0
2
0
2
0


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


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))


A.sort()
A.append(N + 1)
ans = [0] * (N+1)
count = [0, 0]

for i in range(N):
    if count[0] == A[i]:
        count[1] += 1
    else:
        ans[count[0]] = count[1]
        count[0] = A[i]
        count[1] = 1

for j in range(1, N+1):
    print(ans[j])

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

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
m=max(a)
a = Counter(a)
print(a)

for i in range(1, n + 1):
    if i <= m:
        print(a[i])
    else:
        print(0)


Failing test case input:
7
2 4 2 4 2 6

Expected output:
0
3
0
2
0
1
0


Actual output:
Counter({2: 3, 4: 2, 6: 1})
0
3
0
2
0
1
0


Fixed submission (verdict: Accepted):

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
m = max(a)
a = Counter(a)


for i in range(1, n + 1):
    if i <= m:
        print(a[i])
    else:
        print(0)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
Num = int(input())
bossNumsList =  list(map(int, input().split()))

bossNums=[]

for i in range(Num):
  bossNums.append(0)


for i in range(Num-1):
  bossNums[bossNumsList[i]-1] += 1

print(bossNums)


Failing test case input:
7
2 2 3 3 5 4

Expected output:
0
2
2
1
1
0
0


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


Fixed submission (verdict: Accepted):
Num = int(input())
bossNumsList =  list(map(int, input().split()))

bossNums=[]

for i in range(Num):
  bossNums.append(0)


for i in range(Num-1):
  bossNums[bossNumsList[i]-1] += 1

for i in range(Num):
  print(bossNums[i])
Problem: p02707
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):


from typing import *
import collections
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    c = collections.Counter(A+[i+1 for i in range(N)])
    return "\n".join([str(v-1) for v in c.values()])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  
    print(solve(N, A))


if __name__ == '__main__':
    main()


Failing test case input:
7
2 1 2 4 2 7

Expected output:
1
3
0
1
0
0
1


Actual output:
3
1
1
1
0
0
0


Fixed submission (verdict: Accepted):


from typing import *
import collections
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    c = collections.Counter(A+[i+1 for i in range(N)])
    return "\n".join([f'{c[i+1]-1}' for i in range(N)])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  
    print(solve(N, A))


if __name__ == '__main__':
    main()

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections

n = input()
n = int(n)
alist = input().split(" ")
intalist = [int(s) for s in alist]

setalist = list(set(intalist))

c = collections.Counter(intalist)

if n == 1:
    print(0)
else:
    for i in range(0,n):
        try:
            print(c[setalist[i]])
        except IndexError:
            print(0)

Failing test case input:
5
2 1 3 5

Expected output:
1
1
1
0
1


Actual output:
1
1
1
1
0


Fixed submission (verdict: Accepted):
import collections

n = input()
n = int(n)
alist = input().split(" ")
intalist = [int(s) for s in alist]
setalist = list(set(intalist))

c = collections.Counter(intalist)

result = [0] * n
if n == 1:
    print(0)
else:
    for i in range(0,n):
        try:
            result[setalist[i] - 1] = c[setalist[i]]
            
        except IndexError:
            pass
for i in range(0,n):
    print(result[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = [0]+list(map(int, input().split()))
print(a)
ans = [0] * n
for i in range(n):
    if 0 < a[i]:
        ans[a[i]-1] += 1
print(ans)

Failing test case input:
10
1 1 1 2 1 2 1 1 2

Expected output:
6
3
0
0
0
0
0
0
0
0


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


Fixed submission (verdict: Accepted):
n = int(input())
a = [0]+list(map(int, input().split()))

ans = [0] * n
for i in range(n):
    if 0 < a[i]:
        ans[a[i]-1] += 1
for i in ans:
    print(i)
Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = input().split()
B = [0]*(N)
for i in range(0, len(A)):
    A[i] = int(A[i])
    B[A[i]-1] += 1

print(B)


Failing test case input:
5
1 2 4 5

Expected output:
1
1
0
1
1


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


Fixed submission (verdict: Accepted):
N = int(input())
A = input().split()
B = [0]*(N)
for i in range(0, len(A)):
    A[i] = int(A[i])
    B[A[i]-1] += 1

for i in B:
    print(i)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A=list(map(int, input().split()))
ans=[0]*N
for a in A:
  ans[a-1]+=1
print(ans)

Failing test case input:
5
1 1 2 2

Expected output:
2
2
0
0
0

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


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int, input().split()))
ans=[0]*N
for a in A:
  ans[a-1]+=1
for n in ans:
  print(n)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    N = int( input())
    A = list( map( int, input().split()))
    B = [0]*(N)
    for a in A:
        
        B[a-1] += 1
        print(B)
    print("\n".join( map( str, B)))
if __name__ == '__main__':
    main()


Failing test case input:
7
1 2 3 4 5 6

Expected output:
1
1
1
1
1
1
0

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


Fixed submission (verdict: Accepted):
def main():
    N = int( input())
    A = list( map( int, input().split()))
    B = [0]*(N+1)
    for a in A:
        B[a] += 1
    print("\n".join( map( str, B[1:])))
if __name__ == '__main__':
    main()

Problem: p02707
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import collections

n = int(input())
List = list(map(int, input().split()))
Col = collections.Counter(List)
CountList = list(Col.values()) 
for i in range(n-len(CountList)):
    CountList.append(0)

for i in CountList:
    print(i)



Failing test case input:
7
1 3 2 2 1 6

Expected output:
2
2
1
0
0
1
0


Actual output:
2
1
2
1
0
0
0


Fixed submission (verdict: Accepted):
import collections

n = int(input())
List = list(map(int, input().split()))
Col = collections.Counter(List)
Col2 = sorted(Col.items())
CountList = [0]*n
for i in Col2:
    CountList[i[0]-1] = i[1]




for i in CountList:
    print(i)

Problem: p02707
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
worker_list = [0] * N
print(worker_list)
print(A)
for i in range(0, N - 1):
    worker_list[A[i] - 1] += 1

for i in range(N):
    print(worker_list[i])


Failing test case input:
7
1 1 3 3 3 4

Expected output:
2
0
3
1
0
0
0


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


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
worker_list = [0] * N

for i in range(0, N - 1):
    worker_list[A[i] - 1] += 1

for i in range(N):
    print(worker_list[i])
Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections
N = int(input())
t = list(map(int, input().split()))

C = collections.Counter(t)
ans = [0]*N
for i in range(N):
    ans[i] = C[i+1]
    
print(ans)

Failing test case input:
7
1 2 2 1 5 4

Expected output:
2
2
0
1
1
0
0


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


Fixed submission (verdict: Accepted):
import collections
N = int(input())
t = list(map(int, input().split()))

C = collections.Counter(t)
for i in range(N):
    print(C[i+1])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
for i in range(N-1):
    B[A.pop()-1]+=1
for i in B:
    print(B[i])

Failing test case input:
7
1 2 3 4 5 4

Expected output:
1
1
1
2
1
0
0


Actual output:
1
1
1
1
1
1
1


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
for i in range(N-1):
    B[A.pop()-1]+=1
for i in range(N):
    print(B[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
dict = {}
for i in map(int, input().split(" ")):
	dict[i] = dict.get(i, 0) + 1
 
for i in range(0, n + 1):
	print(dict.get(i, 0))

Failing test case input:
7
1 2 3 6 5 2

Expected output:
1
2
1
0
1
1
0


Actual output:
0
1
2
1
0
1
1
0


Fixed submission (verdict: Accepted):
n = int(input())
dict = {}
for i in map(int, input().split(" ")):
	dict[i] = dict.get(i, 0) + 1
 
for i in range(1, n + 1):
	print(dict.get(i, 0))

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections
N = int(input())
A = list(map(int, input().split()))

c = collections.Counter(A)
print(c)

for i in range(N):
    print(c[i+1])

Failing test case input:
7
1 3 1 4 2 7

Expected output:
2
1
1
1
0
0
1


Actual output:
Counter({1: 2, 3: 1, 4: 1, 2: 1, 7: 1})
2
1
1
1
0
0
1


Fixed submission (verdict: Accepted):
import collections
N = int(input())
A = list(map(int, input().split()))

c = collections.Counter(A)

for i in range(N):
    print(c[i+1])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
a = [0] + a
cnt = defaultdict(lambda :0)

for i in a:
    cnt[i - 1] += 1

for i in a:
    print(cnt[i])
    cnt[i] = 0


Failing test case input:
7
2 5 1 4 3 7

Expected output:
1
1
1
1
1
0
1


Actual output:
1
1
0
1
1
1
0


Fixed submission (verdict: Accepted):
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))

cnt = defaultdict(lambda :0)
for i in a:
    cnt[i] += 1

for i in range(1, n + 1):
    print(cnt[i])
Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a_list = list(map(int, input().split(" ")))

i = 0
for target_val in range(1, n + 1):
    cnt = 0
    while target_val == a_list[min(i, len(a_list) - 1)] and i < len(a_list):
        i += 1
        cnt += 1
    print(cnt)


Failing test case input:
5
1 4 1 5

Expected output:
2
0
0
1
1


Actual output:
1
0
0
1
0


Fixed submission (verdict: Accepted):
n = int(input())
a_list = sorted(list(map(int, input().split(" "))))

i = 0
for target_val in range(1, n + 1):
    cnt = 0
    while target_val == a_list[min(i, len(a_list) - 1)] and i < len(a_list):
        i += 1
        cnt += 1
    print(cnt)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = input()
num = list(map(int,input().split()))

num.sort()
cnt = 0
work = 0
sum = 0
flg = 0
for i in num:
  if work != i:
    if work != 0:
      print(cnt)
      sum += 1
    cnt = 1
    work += 1
  elif work == i:
    cnt += 1

print(cnt)
sum += 1
sum = int(n) - sum
for i in range(sum):
  print(0)

Failing test case input:
7
1 2 1 4 5 6

Expected output:
2
1
0
1
1
1
0


Actual output:
2
1
1
1
1
0
0


Fixed submission (verdict: Accepted):
n = input()
num = list(map(int,input().split()))

num.sort()
cnt = 0
work = 0
sum = 0
flg = 0
for i in num:
  if work != i:
    if work != 0:
      print(cnt)
      sum += 1
    cnt = 1
    mae = work + 1
    work = i
    if mae != work:
      for i in range(mae,work):
        print(0)
        sum += 1
  elif work == i:
    cnt += 1
  

print(cnt)
sum += 1
sum = int(n) - sum
for i in range(sum):
  print(0)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

m = Counter(a)

for i in range(1,n):
  print(m[i])
  

Failing test case input:
10
1 1 1 2 1 2 1 1 2

Expected output:
6
3
0
0
0
0
0
0
0
0


Actual output:
6
3
0
0
0
0
0
0
0


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

m = Counter(a)

for i in range(1,n+1):
  print(m[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter
n = input()
l = input().split()
lt = [int(i) for i in l]
f = Counter(l)
for i in lt:
    print(f[str(i+1)])


Failing test case input:
10
1 1 1 2 1 2 2 1 2

Expected output:
5
4
0
0
0
0
0
0
0
0


Actual output:
4
4
4
0
4
0
0
4
0


Fixed submission (verdict: Accepted):
from collections import Counter
n = list(range(int(input())))
l = input().split()
lt = [int(i) for i in l]
f = Counter(l)
for i in n:
    print(f[str(i+1)])
Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter
a=int(input())
l=list(map(int,input().split()))
d=Counter(l)
print(d)
for i in range(1,a+1):
    if i in d:
        print(d[i])
    else:
        print("0")

Failing test case input:
7
2 2 2 1 5 3

Expected output:
1
3
1
0
1
0
0


Actual output:
Counter({2: 3, 1: 1, 5: 1, 3: 1})
1
3
1
0
1
0
0


Fixed submission (verdict: Accepted):
from collections import Counter
a=int(input())
l=list(map(int,input().split()))
d=Counter(l)

for i in range(1,a+1):
    if i in d:
        print(d[i])
    else:
        print("0")

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    import collections

    C = collections.Counter(A)
    for a, b in C.items():
        print(b)
    for _ in range(N-len(C)):
        print(0)


if __name__ == '__main__':
    main()


Failing test case input:
7
2 3 1 4 2 7

Expected output:
1
2
1
1
0
0
1


Actual output:
2
1
1
1
1
0
0


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    import collections

    C = collections.Counter(A)
    m = max(A)
    for i in range(m):
        print(C[i+1])

    for _ in range(N-m):
        print(0)


if __name__ == '__main__':
    main()

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(int(i) for i in input().split())

p = [0] * n

for i in p:
  for j in a:
    if(i == j - 1):
      p[i] += 1

for i in p:
  print(i)


Failing test case input:
7
1 5 3 5 5 6

Expected output:
1
0
1
0
3
1
0


Actual output:
7
0
0
0
0
0
0


Fixed submission (verdict: Accepted):
n = int(input())
a = list(int(i) for i in input().split())

p = [0] * n

for i in a:
    p[i - 1] += 1

for i in p:
  print(i)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

man=1
cnt=0
man_list=[0]*N
A += [0]

for a in A:
  if a != man:
    man_list[man-1] = cnt
    man = a
    cnt=0
  cnt+=1

for l in man_list:
  print(l)

Failing test case input:
7
1 2 2 1 5 4

Expected output:
2
2
0
1
1
0
0


Actual output:
1
2
0
1
1
0
0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

man=1
cnt=0
man_list=[0]*N
A.sort()
A += [0]

for a in A:
  if a != man:
    man_list[man-1] = cnt
    man = a
    cnt=0
  cnt+=1

for l in man_list:
  print(l)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N):
  count = 0
  for i in range(1,N):
    if A[i-1] == i:
      count += 1
  print(count)
print(0)

Failing test case input:
7
1 2 2 4 5 6

Expected output:
1
2
0
1
1
1
0


Actual output:
5
5
5
5
5
5
0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
l = [0]*N
for i in range(1,N):
  l[A[i-1]-1] += 1
for i in range(N):
  print(l[i])
Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections
N = int(input())
A = input().split()
clist = collections.Counter(A)
for i in range(1,N):
  print(clist['i'])

Failing test case input:
7
2 4 2 4 2 6

Expected output:
0
3
0
2
0
1
0


Actual output:
0
0
0
0
0
0


Fixed submission (verdict: Accepted):
import collections
N = int(input())
A = list(map(int, input().split()))
clist = collections.Counter(A)
for i in range(1,N + 1):
  print(clist[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections

N = int(input())
M = list(map(int,input().split()))

c = collections.Counter(M)



for i in c.values():
    print(i)

for j in range(N-len(c)):
    print("0")

Failing test case input:
7
1 2 2 4 5 4

Expected output:
1
2
0
2
1
0
0


Actual output:
1
2
2
1
0
0
0


Fixed submission (verdict: Accepted):
import collections

N = int(input())
M = list(map(int,input().split()))

c = collections.Counter(M)



for i in range(1,N+1):
    if i in c.keys():
        print(c[i])
    else:
        print(0)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter


N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
print(c)
for i in range(1, N + 1):
    print(c[i])

Failing test case input:
7
2 2 6 2 3 7

Expected output:
0
3
1
0
0
1
1


Actual output:
Counter({2: 3, 6: 1, 3: 1, 7: 1})
0
3
1
0
0
1
1


Fixed submission (verdict: Accepted):
from collections import Counter


N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
for i in range(1, N + 1):
    print(c[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    import collections

    C = collections.Counter(A)
    for a in A:
        try:
            print(C[a+1])
        except:
            print(0)


if __name__ == '__main__':
    main()


Failing test case input:
7
1 2 3 1 7 2

Expected output:
2
2
1
0
0
0
1


Actual output:
2
1
0
2
0
1


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    import collections

    C = collections.Counter(A)
    m = max(A)
    for i in range(m):
        print(C[i+1])

    for _ in range(N-m):
        print(0)


if __name__ == '__main__':
    main()

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
alist = list(map(int,input().split()))
print(alist)
num_b = [0]*(n+1)
for i in range(n-1):
    num_b[alist[i]] += 1 
for i in range(1,n+1):
    print(num_b[i])

Failing test case input:
7
1 2 1 4 1 7

Expected output:
3
1
0
1
0
0
1


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


Fixed submission (verdict: Accepted):
n = int(input())
alist = list(map(int,input().split()))
num_b = [0]*(n+1)
for i in range(n-1):
    num_b[alist[i]] += 1 
for i in range(1,n+1):
    print(num_b[i])
Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A_lis=list(map(int,input().split()))
p=[0]*N
for i in A_lis:
  p[i-1]+=1

for _ in p:
  print(p[_])

Failing test case input:
7
2 2 3 5 5 6

Expected output:
0
2
1
0
2
1
0


Actual output:
0
1
2
0
1
2
0


Fixed submission (verdict: Accepted):
N=int(input())
A_lis=list(map(int,input().split()))
p={i:0 for i in range(1,N+1)} 
for j in A_lis:
    p[j]+=1
 
for i in range(1,N+1):
    print(p[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
for ret in c.values():
    print(ret)
print(0)

Failing test case input:
7
1 2 3 4 1 6

Expected output:
2
1
1
1
0
1
0


Actual output:
2
1
1
1
1
0


Fixed submission (verdict: Accepted):
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
for i in range(1,n+1):
    print(c[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A_r=list(input().split())
A=[int(x) for x in A_r]
B=[0 for i in range(N)]
print(B)
for i in range(len(A)):
    B[A[i]-1]+=1
[print(i) for i in B]

Failing test case input:
7
1 2 3 4 7 6

Expected output:
1
1
1
1
0
1
1


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


Fixed submission (verdict: Accepted):
N=int(input())
A_r=list(input().split())
A=[int(x) for x in A_r]
B=[0 for i in range(N)]

for i in range(len(A)):
    B[A[i]-1]+=1
for i in range(len(B)):
    print(B[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
now = 1
sum = 0
for i in sorted(list(map(int,input().split()))):
    if(now == i):
        sum += 1
    else:
        for j in range(i - now -1):
            print(0)
        print(sum)
        sum = 1
        now = i
else:
    print(sum)
while(now < N):
    print(0)
    now += 1


Failing test case input:
7
2 2 2 1 5 3

Expected output:
1
3
1
0
1
0
0


Actual output:
1
3
0
1
1
0
0


Fixed submission (verdict: Accepted):
N = int(input())
sum = 0
now = 1
for i in sorted(list(map(int,input().split()))):
    if(now == i):
        sum += 1
    else:
        print(sum)
        for j in range(i-now-1):
            print(0)
        now = i
        sum = 1
else:
    print(sum)
while(now < N):
    now += 1
    print(0)

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split())) 

B = [0] * N

for i in range(N-1):
    B[A[i]-1] += A[i]
    
[print(B[i]) for i in range(N)]

Failing test case input:
7
1 2 1 4 1 7

Expected output:
3
1
0
1
0
0
1


Actual output:
3
2
0
4
0
0
7


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split())) 

B = [0] * N

for i in range(N-1):
    B[A[i]-1] += int(A[i]/A[i])
    
[print(B[i]) for i in range(N)]
Problem: p02707
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
A =[int(x) for x in input().split()]
ans = [0] * n
for i in range(n-1):
    ans[A[i]-1] +=1

for i in ans:
    print(ans[i])

Failing test case input:
7
2 2 2 1 5 3

Expected output:
1
3
1
0
1
0
0


Actual output:
3
0
3
1
3
1
1


Fixed submission (verdict: Accepted):
n = int(input())
A =[int(x) for x in input().split()]
ans = [0] * n
for i in range(n-1):
    ans[A[i]-1] +=1

for i in range(n):
    print(ans[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections
N = int(input())
A = input().split()
clist = collections.Counter(A)
for i in range(1,N):
  j = str(i)
  print(clist['i'])

Failing test case input:
5
2 4 4 3

Expected output:
0
1
1
2
0


Actual output:
0
0
0
0


Fixed submission (verdict: Accepted):
import collections
N = int(input())
A = list(map(int, input().split()))
clist = collections.Counter(A)
for i in range(1,N + 1):
  print(clist[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
j=0
c=0
import sys

for i in range(1,n+1):
    while 1:
        if j==n-1:
            
            break
        if i!=a[j]:
            break
        else:
            c+=1
            j+=1
    print(c)
    c=0
    




Failing test case input:
7
1 3 2 4 2 6

Expected output:
1
2
1
1
0
1
0


Actual output:
1
0
1
0
0
0
0


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
j=0
c=0
import sys
a.sort()

for i in range(1,n+1):
    while 1:
        if j==n-1:
            
            break
        if i!=a[j]:
            break
        else:
            c+=1
            j+=1
    print(c)
    c=0

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections
n=int(input())
a=list(map(int, input().split()))
c=collections.Counter(a)
for i in range(n):
    print(c[i])

Failing test case input:
7
1 2 2 2 1 5

Expected output:
2
3
0
0
1
0
0


Actual output:
0
2
3
0
0
1
0


Fixed submission (verdict: Accepted):
import collections
n=int(input())
a=list(map(int, input().split()))
c=collections.Counter(a)
for i in range(1,n+1):
    print(c[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))

Clist = []
for count in range(len(A)+1):
    Clist.append(0)

for count in range(len(A)):
    Clist[A[count]-1] = Clist[A[count]-1] + 1

for count in range(0,len(A)):
    print(Clist[count])

Failing test case input:
7
1 2 2 4 5 4

Expected output:
1
2
0
2
1
0
0


Actual output:
1
2
0
2
1
0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))

Clist = []
for count in range(len(A)+1):
    Clist.append(0)

for count in range(len(A)):
    Clist[A[count]-1] = Clist[A[count]-1] + 1

for count in range(0,len(A)+1):
    print(Clist[count])
Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

lis = [0]*len(a)

for i in range(n-1):
  for j in range(len(a)):
    if a[j] == i+1:
      lis[i] += 1

print(lis)

Failing test case input:
7
1 2 2 3 6 2

Expected output:
1
3
1
0
0
1
0


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


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int,input().split()))

lis = [0] * n
for i in A:
  lis[i-1] += 1

for j in range(len(lis)):
  print(lis[j])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split())))
a=list(a.values())
dif=n-len(a)
for i in range(dif):
	a.append(0)
for j in a:
	print(j)


Failing test case input:
7
2 2 3 5 5 6

Expected output:
0
2
1
0
2
1
0


Actual output:
2
1
2
1
0
0
0


Fixed submission (verdict: Accepted):
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split())))
ans=[0]*n
for i,j in a.items():
	ans[i-1]=j
for k in ans:
	print(k)

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

def main():
    n = int(input())
    a = list(map(int, input().split(' ')))
    buka = [0]*n
    print(a)

    for i in a:
        buka[i-1] += 1

    for i in buka:
        print(i)


if __name__ == "__main__":
    main()


Failing test case input:
7
2 3 1 4 2 7

Expected output:
1
2
1
1
0
0
1


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


Fixed submission (verdict: Accepted):

def main():
    n = int(input())
    a = list(map(int, input().split(' ')))
    buka = [0]*n

    for i in a:
        buka[i-1] += 1

    for i in buka:
        print(i)


if __name__ == "__main__":
    main()

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(n)]
print(ans)

for i in range(n-1):
    ans[A[i]-1] += 1

print(ans)

Failing test case input:
7
2 3 2 4 2 6

Expected output:
0
3
1
1
0
1
0


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


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(n)]
for i in range(n-1):
    ans[A[i]-1] += 1

for i in range(len(ans)):
    print(ans[i])

Problem: p02707
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
k = set(A)
r = set(range(1, N + 1))

for key in r - k:
    c[key] = 0

for v in c.values():
    print(v)


Failing test case input:
7
1 2 3 1 7 2

Expected output:
2
2
1
0
0
0
1


Actual output:
2
2
1
1
0
0
0


Fixed submission (verdict: Accepted):
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
k = set(A)
r = set(range(1, N + 1))

for key in r - k:
    c[key] = 0


for key in r:
    print(c[key])
Problem: p02873
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S = list(input())
before = 0
last_upper = 0
count = 0
answer = 0
for i, s in enumerate(S):
  
  if s == '<':
    if before < 0 and last_upper < i-1:
      answer += abs(before)*(i-last_upper)
      before = 0
    elif before > 0 and last_upper < i-1:
      answer -= before*(i-last_upper-1)
      before = 0
    before += 1
    answer += before
    last_upper = i
  else:
    before -= 1
    answer += before

if before < 0:
  answer += abs(before)*(len(S)-last_upper)
elif before > 0:
  answer -= before*(len(S)-last_upper-1)
print(answer)


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

Expected output:
25


Actual output:
18


Fixed submission (verdict: Accepted):
S = list(input())
before = 0
last_upper = -1
count = 0
answer = 0
for i, s in enumerate(S):
  
  if s == '<':
    if before < 0 and last_upper < i-1:
      answer += abs(before)*(i-last_upper)
      before = 0
    elif before > 0 and last_upper < i-1:
      answer -= before*(i-last_upper-1)
      before = 0
    before += 1
    answer += before
    last_upper = i
  else:
    before -= 1
    answer += before

if before < 0:
  answer += abs(before)*(len(S)-last_upper)
elif before > 0:
  answer -= before*(len(S)-last_upper-1)
print(answer)

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

total = 0
tmp_current = 0
tmp_high = 0
count_from_high = 0
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:
2


Actual output:
1


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 (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
s=input().rstrip()
print(s)
ls=len(s)
L=[0]*(ls+1)

pre,n='<',0
for i,c in enumerate(s):
    if c=='<':
        if pre == '<':
            n+=1
            L[i+1]=n
        else:
            n=1
            L[i+1]=1
            pre='<'
    else:
        pre='>'

pre,n='>',0
for i,c in enumerate(s[::-1]):
    if c=='>':
        if pre == '>':
            n+=1
            L[ls-1-i]=max(n,L[ls-1-i])
        else:
            n=1
            L[ls-1-i]=max(n,L[ls-1-i])
            pre='>'
    else:
        pre='<'
print(sum(L))

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

Expected output:
14


Actual output:
<<<><><><><><>><
14


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
s=input().rstrip()
ls=len(s)
L=[0]*(ls+1)

pre,n='<',0
for i,c in enumerate(s):
    if c=='<':
        if pre == '<':
            n+=1
            L[i+1]=n
        else:
            n=1
            L[i+1]=1
            pre='<'
    else:
        pre='>'

pre,n='>',0
for i,c in enumerate(s[::-1]):
    if c=='>':
        if pre == '>':
            n+=1
            L[ls-1-i]=max(n,L[ls-1-i])
        else:
            n=1
            L[ls-1-i]=max(n,L[ls-1-i])
            pre='>'
    else:
        pre='<'
print(sum(L))

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

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

Expected output:
45


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 = list(input())
num = 0
n = len(s)
l = []
i = 0
while i < n:
  if s[i] == '<':
    l.append(num)
    num+=1
    i+=1
    if i==n:
      l.append(num)
  else:
    cur = 0
    while i < n and s[i]=='>':
      l.append(cur)
      i+=1
      cur+=1
    num = 1
    if i==n:
      l.append(cur)
print(sum(l))

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

Expected output:
23


Actual output:
24


Fixed submission (verdict: Accepted):
s = list(input())
num = 0
n = len(s)
l = []
i = 0
while i < n:
  if s[i] == '<':
    l.append(num)
    num+=1
    i+=1
    if i==n:
      l.append(num)
  else:
    cur = 0
    while i < n and s[i]=='>':
      i+=1
      cur+=1
    if cur <= num:
      l.append(num)
      cur-=1
    l.append((cur*(cur+1))
    num = 0
print(sum(l))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input().strip()
N = len(S)+1
A = [0 for _ in range(N)]
B = []
for i in range(N):
    if i==0 and S[i]=="<":
        B.append(0)
    elif i<N-2 and S[i]==">" and S[i+1]=="<":
        B.append(i+1)
    elif i==N-2 and S[i]==">":
        B.append(i+1)
for j in range(len(B)-1):
    ind0 = B[j]
    ind1 = B[j+1]
    c = ind0
    while S[c]=="<":
        A[c+1] = max(A[c+1],A[c]+1)
        c += 1
    c = ind1
    while S[c-1]==">":
        A[c-1] = max(A[c-1],A[c]+1)
        c -= 1
c = B[-1]
if c<N-1:
    for i in range(c+1,N):
        A[i] = A[i-1]+1
print(sum(A))

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

Expected output:
40


Actual output:
30


Fixed submission (verdict: Accepted):
S = input().strip()
N = len(S)+1
A = [0 for _ in range(N)]
B = []
for i in range(N):
    if i==0 and S[i]=="<":
        B.append(0)
    elif i<N-2 and S[i]==">" and S[i+1]=="<":
        B.append(i+1)
    elif i==N-2 and S[i]==">":
        B.append(i+1)
for j in range(len(B)-1):
    ind0 = B[j]
    ind1 = B[j+1]
    c = ind0
    while S[c]=="<":
        A[c+1] = max(A[c+1],A[c]+1)
        c += 1
    c = ind1
    while S[c-1]==">":
        A[c-1] = max(A[c-1],A[c]+1)
        c -= 1
c = B[0]
if c>0:
    for i in range(c-1,-1,-1):
        A[i] = A[i+1]+1
c = B[-1]
if c<N-1:
    for i in range(c+1,N):
        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)-2,0,-1):
    if S[i]=='>':
        A[i]=max(A[i],A[i+1]+1)

print(sum(A))


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

Expected output:
37


Actual output:
33


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 = list(input())
num = 0
n = len(s)
l = []
i = 0
while i < n:
  if s[i] == '<':
    l.append(num)
    num+=1
    i+=1
    if i==n:
      l.append(num)
  else:
    cur = 1
    while i < n and s[i]=='>':
      l.append(cur)
      i+=1
      cur+=1
    num = 0
print(sum(l))

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

Expected output:
22


Actual output:
19


Fixed submission (verdict: Accepted):
s = list(input())
num = 0
n = len(s)
l = []
i = 0
while i < n:
  if s[i] == '<':
    l.append(num)
    num+=1
    i+=1
    if i==n:
      l.append(num)
  else:
    cur = 0
    while i < n and s[i]=='>':
      i+=1
      cur+=1
    if cur <= num:
      l.append(num)
      cur-=1
    l.append((cur*(cur+1))
    num = 0
print(sum(l))

Problem: p02873
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(str(input()))
N = len(S) + 1

a = [0]*N

for i, s in enumerate(S):
  if s=="<":
    a[i+1]=a[i]+1

S_ = list(reversed(S))
j=0
for s in S_:
  if s==">":
    a[N-1-j-1]=a[N-1-j]+1
  j+=1
print(sum(a))

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

Expected output:
28


Actual output:
25


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

a = [0]*N

for i, s in enumerate(S):
  if s=="<":
    a[i+1]=a[i]+1

S_ = list(reversed(S))
j=0
for s in S_:
  if s==">":
    if a[N-1-(j+1)]<=a[N-1-j]:
      a[N-1-(j+1)]=a[N-1-j]+1
  j+=1
print(sum(a))

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

for i in range(n-1):
    if s[i] == "<":
        v[i+1] = v[i] + 1

for j in range(n-1):
    if s[-j-1] == ">":
        v[-j-2] = v[-j-1] + 1

print(sum(v))

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

Expected output:
19


Actual output:
18


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

for i in range(n-1):
    if s[i] == "<":
        v[i+1] = v[i] + 1

for j in range(n-1):
    if s[-j-1] == ">":
        if v[-j-2] <= v[-j-1]:
            v[-j-2] = v[-j-1] + 1

print(sum(v))

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

s = str(input())

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

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

s = s.split('0')

sum = 0

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

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

Expected output:
17


Actual output:
17.0


Fixed submission (verdict: Accepted):
import re

s = str(input())

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

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

s = s.split('0')

sum = 0

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


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

print(l)

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

    print(res)

print(int(res))


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

Expected output:
31


Actual output:
[('>', 1), ('<', 5), ('>', 2), ('<', 3), ('>', 4), ('<', 1)]
16.0
17.0
23.0
30.0
31.0
31


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 = list(input())
l_ans = [0 for _ in range(len(s)+1)]
r_ans = [0 for _ in range(len(s)+1)]
ans = [0 for _ in range(len(s)+1)]
l_level = 0
r_level = 0
for i in range(len(s)):
    if s[i] == '<':
        l_level += 1
    else:
        l_level = 0
    l_ans[i+1] = l_level

for i in range(len(s)):
    if s[-i] == '<':
        r_level = 0
    else:
        r_level += 1
    r_ans[-(i+1)] = r_level

for i in range(len(ans)):
    ans[i] = max(l_ans[i], r_ans[i])
print(sum(ans))


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

Expected output:
25


Actual output:
24


Fixed submission (verdict: Accepted):
s = list(input())
l_ans = [0 for _ in range(len(s)+1)]
r_ans = [0 for _ in range(len(s)+1)]
ans = [0 for _ in range(len(s)+1)]
l_level = 0
r_level = 0
for i in range(len(s)):
    if s[i] == '<':
        l_level += 1
    else:
        l_level = 0
    l_ans[i+1] = l_level

for i in range(1,len(s)+1):
    if s[-i] == '<':
        r_level = 0
    else:
        r_level += 1
    r_ans[-(i+1)] = r_level

for i in range(len(ans)):
    ans[i] = max(l_ans[i], r_ans[i])


print(sum(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)])


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 len(sg)>=left:
            ans += calc(len(sg))
        else:
            ans += calc(len(sg)-1)
        right = len(sg)
    else:
        if len(sg)>=right or i!=len(l)-1:
            ans += calc(len(sg))
        else:
            ans += calc(len(sg)-1)
        left = len(sg)

print(ans)

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

Expected output:
22


Actual output:
25


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)