Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import  heapq
n = int(input())
num = [int(i) for i in input().split()]
count1 = 0

for i in range(len(num)):
    num1 = num[:i+1].copy()
    heapq.heapify(num1)
    if heapq.heappop(num1) == num[i]:
        count1 += 1
        
print(count1)

### FIXED CODE ###

n = int(input())
num = [int(i) for i in input().split()]
count1 = 0
minv = 0

for i in range(len(num)):
    if i ==0:
        count1 +=1
        minv = num[i]
        
    elif minv >= num[i]:
        minv = num[i]
        count1 +=1
print(count1)
### BUGGY CODE ###

H,N = map(int,input().split())
magic = [list(map(int,input().split())) for i in range(N)]

INF = 10**9

dp = [INF for i in range(H+1)]
dp[0] = 0

for i in range(1,H+1):
    for j in range(N):
        dp[i] = min(dp[max(0,i-magic[j][0])]+magic[j][1],dp[i])
print(dp[H])


### FIXED CODE ###

H,N = map(int,input().split())
magic = [list(map(int,input().split())) for i in range(N)]

INF = 10**10
#print(magic)

AM = 0
for i in range(N):
    AM = max(AM,magic[i][0])
#print(AM)


dp = [INF for i in range(H+AM+1)]
dp[0] = 0

for i in range(1,H+AM+1):
    for j in range(N):
        if magic[j][0] > i:
            dp[i] = min(dp[i],magic[j][1])
        else:
            dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i])
ans = INF
for i in range(H,H+AM+1):
    ans = min(ans,dp[i])
print(ans)
### BUGGY CODE ###

#-------------------------------------------------------------------
#-------------------------------------------------------------------
# import io
# import sys

# _INPUT = """\
# 20 200000
# 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# """
# sys.stdin = io.StringIO(_INPUT)

#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------
import sys
def p(*_a):
  #return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------

N,K = map(int, input().split())

A = list( map(int, input().split()) )	# 1 2 3 4 5 ...

from itertools import accumulate

for k in range(K):
  B=[0]*N
  for i,d in enumerate(A):
    l = max(0, i-d)
    r = i+d+1

    B[l]+=1
    if r<N: B[r]-=1

  A = list(accumulate(B))
  if A.count(N)==N: break
  # p("A=",A)
  # p("B=",B)

print(*A)


### FIXED CODE ###

N,K = map(int, input().split())

A = list( map(int, input().split()) )	# 1 2 3 4 5 ...

from itertools import accumulate

for _ in range(K):
  B=[0]*N
  for i,d in enumerate(A):
    l = max(0, i-d)
    r = i+d+1

    B[l]+=1
    if r<N: B[r]-=1

  A = list(accumulate(B))
  if A.count(N)==N: break
  # p("A=",A)
  # p("B=",B)

print(*A)
### BUGGY CODE ###

import numpy as np

k=int(input())
ans=0
for a in range(1,k+1):
    for b in range(1,a+1):
        for c in range(1,b+1):
            if (a==b) and (b==c):
                ans+=np.gcd(a,np.gcd(b,c))
            if ((a!=b) and (b==c)) or ((a==b) and (b!=c)):
                ans+=3*np.gcd(a,np.gcd(b,c))
            if ((a!=b) and (b!=c)):
                ans+=6*np.gcd(a,np.gcd(b,c))
print(ans)

### FIXED CODE ###

import math

k=int(input())
ans=0
for a in range(1,k+1):
    for b in range(1,a+1):
        for c in range(1,b+1):
            if (a==b) and (b==c):
                ans+=math.gcd(a,math.gcd(b,c))
            if ((a!=b) and (b==c)) or ((a==b) and (b!=c)):
                ans+=3*math.gcd(a,math.gcd(b,c))
            if ((a!=b) and (b!=c)):
                ans+=6*math.gcd(a,math.gcd(b,c))
print(ans)
### BUGGY CODE ###

from bisect import bisect_left

n,m = map(lambda x: int(x), input().split())
a = sorted(list(map(lambda x: int(x),input().split())))

for i in range(m):
    x = bisect_left(a,a[n-1] // 2)
    a.insert(x,a[n-1] // 2)
    a.pop(n)
print(sum(a))


### FIXED CODE ###

import heapq
n,m = map(lambda x: int(x), input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)

for _ in range(m):
    max = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-max//2))
print(-sum(a))
### BUGGY CODE ###

n = int(input())
tops = list(map(int, input().split()))
mids = list(map(int, input().split()))
bottoms = list(map(int, input().split()))

max_mids = max(mids)
max_bottoms = max(bottoms)

tops = [t for t in tops if t < max_mids]
mids = [m for m in mids if m < max_bottoms]

sets = []

# for t,m,b in product(tops,mids,bottoms):
#     if t < m and m < b:
#         sets.append((t,m,b))

for t in tops:
    for m in mids:
        if t < m:
            for b in bottoms:
                if m < b:
                    sets.append((t,m,b))

print(len(sets))

### FIXED CODE ###

import bisect

n = int(input())
tops = list(map(int, input().split()))
mids = list(map(int, input().split()))
bottoms = list(map(int, input().split()))

tops.sort()
bottoms.sort()

nos_sets = 0

for m in mids:
    t = bisect.bisect_left(tops, m)
    b = n - bisect.bisect_right(bottoms, m)
    nos_sets += t * b

print(nos_sets)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    maze = [input() for _ in range(H)]

    left = [[0] * W for _ in range(H)]
    right = [[0] * W for _ in range(H)]
    up = [[0] * W for _ in range(H)]
    down = [[0] * W for _ in range(H)]

    for h in range(H):
        cnt = 0
        for w in range(W):
            if maze[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                left[h][w] = cnt

    for h in range(H):
        cnt = 0
        for w in range(W - 1, -1, -1):
            if maze[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                right[h][w] = cnt

    for w in range(W):
        cnt = 0
        for h in range(H):
            if maze[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                up[h][w] = cnt

    for w in range(W):
        cnt = 0
        for h in range(H - 1, -1, -1):
            if maze[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                down[h][w] = cnt

    ans = 0
    for h in range(H):
        for w in range(W):
            tmp = up[h][w] + down[h][w] + left[h][w] + right[h][w] - 3
            if tmp > ans:
                ans = tmp

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    maze = [input() for _ in range(H)]

    left = [[0] * W for _ in range(H)]
    right = [[0] * W for _ in range(H)]
    up = [[0] * W for _ in range(H)]
    down = [[0] * W for _ in range(H)]

    for h in range(H):
        cnt = 0
        for w in range(W):
            if maze[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                left[h][w] = cnt

    for h in range(H):
        cnt = 0
        for w in range(W - 1, -1, -1):
            if maze[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                right[h][w] = cnt

    for w in range(W):
        cnt = 0
        for h in range(H):
            if maze[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                up[h][w] = cnt

    for w in range(W):
        cnt = 0
        for h in range(H - 1, -1, -1):
            if maze[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                down[h][w] = cnt

    ans = 0
    for h in range(H):
        for w in range(W):
            tmp = up[h][w] + down[h][w] + left[h][w] + right[h][w] - 3
            if tmp > ans:
                ans = tmp

    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
nums = [int(input()) for _ in range(N)]
nums_del = nums

for i in range(len(nums)):
  pop = nums_del.pop(i)
  print(max(nums_del))
  nums_del.insert(i,pop)

### FIXED CODE ###

import numpy as np
N = int(input())
nums = [int(input()) for _ in range(N)]
nums = np.array(nums)
max_num = max(nums)
max_index = np.where(nums == nums.max())[0]

if len(max_index) == 1:
  for i in range(len(nums)):
    if i == max_index[0]:
      print(sorted(nums)[-2])
    else:
      print(max_num)
else:
  for i in range(len(nums)):
    print(max_num)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    if a[i] == 0:
        print(0)
        exit()
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        break
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

S = input()
slen = len(S)
i = int(0)
j = int(0)
while slen >= i:
	if (i%2 == 1 and S[i] == "R","U","D"):
		j = 0
	elif (i%2 == 0 and S[i] == "L","U","D"):
		j = 0
	else:
		j += 1
	i+1
if j == 0:
	print("No")
else:
	print("Yes")

### FIXED CODE ###

S = list(input())
if False not in [i not in "L" for i in S[::2]] and False not in [i not in "R"for i in S[1::2]]:
	print("Yes")
else:
	print("No")
### BUGGY CODE ###

N, M, L = map(int, input().split())
INF = float('inf')

dist = [[INF] * N for _ in range(N)]

for _ in range(M):
    fr, to, cost = map(int, input().split())
    fr -= 1
    to -= 1
    dist[fr][to] = cost
    dist[to][fr] = cost

for i in range(N):
    dist[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

fuel = [[INF] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if dist[i][j] <= L:
            fuel[i][j] = 1

for i in range(N):
    fuel[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            fuel[i][j] = min(fuel[i][j], fuel[i][k] + fuel[k][j])

Q = int(input())
ans = []
for _ in range(Q):
    start, end = map(int, input().split())
    start -= 1
    end -= 1

    ans.append(fuel[start][end] - 1 if fuel[start][end] != INF else -1)

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


### FIXED CODE ###

import sys
input = sys.stdin.readline
INF = float('inf')

N, M, L = map(int, input().split())
ABC = [tuple(map(int, input().split())) for _ in range(M)]
Q = int(input())
ST = [tuple(map(int, input().split())) for _ in range(Q)]

dist = [[INF] * N for _ in range(N)]
fuel = [[INF] * N for _ in range(N)]

for i in range(N):
    dist[i][i] = 0
    fuel[i][i] = 0

for fr, to, cost in ABC:
    if cost > L:
        continue
    fr -= 1
    to -= 1
    dist[fr][to] = cost
    dist[to][fr] = cost

for k in range(N):
    for i in range(N):
        for j in range(N):
            d = dist[i][k] + dist[k][j]
            if dist[i][j] > d:
                dist[i][j] = d
            if d <= L:
                fuel[i][j] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            d = fuel[i][k] + fuel[k][j]
            if fuel[i][j] > d:
                fuel[i][j] = d

for start, end in ST:
    print(fuel[start - 1][end - 1] - 1 if fuel[start - 1][end - 1] != INF else -1)
### BUGGY CODE ###

from bisect import insort_left

X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
i = 0
j = 0
k = 0
while(True):
    if P[j] >= R[i] and Q[k] >= R[i]:
        break
    if P[j] > Q[k]:
        if Q[k] < R[i]:
            insort_left(Q, R[i])
            k += 1
    else:
        if P[j] < R[i]:
            insort_left(P, R[i])
            j += 1
    i += 1
    if i == len(R):
        break
print(sum(P[j:]) + sum(Q[k:]))

### FIXED CODE ###

import heapq
 
X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
heapq.heapify(P)
heapq.heapify(Q)
i = 0
while(True):
    if P[0] >= R[i] and Q[0] >= R[i]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[i]:
            heapq.heappop(Q)
            heapq.heappush(Q, R[i])
    else:
        if P[0] < R[i]:
            heapq.heappop(P)
            heapq.heappush(P, R[i])
    i += 1
    if i == len(R):
        break
print(sum(P) + sum(Q))
### BUGGY CODE ###

import sys
def SI(): return sys.stdin.readline().strip()

def main():
    s = SI()
    t = SI()

    d = {}
    for i, c in enumerate(s):
        if c not in d:
            d[c] = [i]
        else:
            d[c].append(i)

    import collections
    didx = collections.defaultdict(int)

    keys = d.keys()
    for c in set(t):
        if c not in keys:
            print(-1)
            return

    import bisect

    i_loop = 0
    currentidx = -1
    for c in t:
        # 次の文字を読む
        poslist = d[c]

        if len(poslist) <= didx[c]:
            # 文字を取り切っている場合は次のループに
            i_loop += 1
            didx = collections.defaultdict(int)
            currentidx = poslist[0]
            didx[c] += 1
        else:
            # とり切っていない場合
            poslist_afteridx = poslist[didx[c]:]
            posidx = bisect.bisect_right(poslist_afteridx, currentidx)

            if posidx >= len(poslist_afteridx):
                # とれないなら次のループでとったことにする
                i_loop += 1
                didx = collections.defaultdict(int)
                currentidx = poslist[0]
                didx[c] += 1
            else:
                # 同じループでとれるなら取って、現在位置を更新
                pos = poslist_afteridx[posidx]
                currentidx = pos
                didx[c] = posidx + 1

    print(len(s)*i_loop + currentidx + 1)

main()

### FIXED CODE ###

import sys
def SI(): return sys.stdin.readline().strip()

def main():
    s = SI()
    t = SI()

    import collections
    d = collections.defaultdict(list)
    for i, c in enumerate(s):
        d[c].append(i)

    keys = d.keys()
    for c in set(t):
        if c not in keys:
            print(-1)
            return

    import bisect

    i_loop = 0
    currentidx = -1
    for c in t:
        # 次の文字を読む
        poslist = d[c]

        # とり切っていない場合
        posidx = bisect.bisect_right(poslist, currentidx)

        if posidx >= len(poslist):
            # とれないなら次のループでとったことにする
            i_loop += 1
            currentidx = poslist[0]
        else:
            # 同じループでとれるなら取って、現在位置を更新
            pos = poslist[posidx]
            currentidx = pos

    print(len(s)*i_loop + currentidx + 1)

main()
### BUGGY CODE ###

import sys
from collections import defaultdict as dd
from collections import deque as dq
input = sys.stdin.readline
N, K = map(int, input().split())
e = dd(list)
for _ in range(N - 1):
  a, b = map(int, input().split())
  e[a].append(b)
  e[b].append(a)
d = [[N for _ in range(N + 1)] for _ in range(N + 1)]
for s in range(1, N + 1):
  Q = dq([s])
  d[s][s] = 0
  while len(Q):
    p = Q.popleft()
    for q in e[p]:
      if d[s][q] > d[s][p] + 1:
        d[s][q] = d[s][p] + 1
        Q.append(q)
vis = set()
table = [set() for _ in range(N + 1)]
for i in range(1, N + 1):
  for j in range(1, N + 1):
    if d[i][j] > K: table[i].add(j)
while True:
  t = 0
  for i in range(1, N + 1):
    if i in vis: continue
    if len(table[i]) > len(table[t]): t = i
  if t == 0: break
  for i in range(1, N + 1):
    table[i].discard(t)
  vis.add(t)
print(len(vis))

### FIXED CODE ###

import sys
from collections import defaultdict as dd
from collections import deque as dq
input = sys.stdin.readline
N, K = map(int, input().split())
e = dd(list)
for _ in range(N - 1):
  a, b = map(int, input().split())
  e[a].append(b)
  e[b].append(a)
d = [[N for _ in range(N + 1)] for _ in range(N + 1)]
for s in range(1, N + 1):
  Q = dq([s])
  d[s][s] = 0
  while len(Q):
    p = Q.popleft()
    for q in e[p]:
      if d[s][q] > d[s][p] + 1:
        d[s][q] = d[s][p] + 1
        Q.append(q)
vis = set()
table = [[0] * (N + 1) for _ in range(N + 1)]
lntable = [0] * (N + 1)
for i in range(1, N + 1):
  for j in range(1, N + 1):
    if d[i][j] > K:
      table[i][j] = 1
      lntable[i] += 1
while True:
  t = 0
  for i in range(1, N + 1):
    if i in vis: continue
    if lntable[i] > lntable[t]: t = i
  if t == 0: break
  for i in range(1, N + 1):
    if table[i][t] == 1:
      table[i][t] = 0
      lntable[i] -= 1
  vis.add(t)
print(len(vis))
### BUGGY CODE ###

N, T = map(int, input().split())
data = []
for i in range(N):
  a, b = map(int, input().split())
  data.append((a,b))
data.sort()

#print(data)

dp = [0] * T
ans = 0
for a, b in data:
  ans = max(ans, dp[-1]+b)
  if a < T:
    eatable = dp[:T-a]
    j = 0
    maxj = len(eatable)
    for i in range(a, T, 1):
      if dp[i] < eatable[j] + b:
        dp[i] = eatable[j] + b
      if not j==maxj:
        j += 1
print(ans)

### FIXED CODE ###

import numpy as np

N, T = map(int, input().split())
data = []
for i in range(N):
  a, b = map(int, input().split())
  data.append((a,b))
data.sort()
data = np.array(data)

#print(data)

dp = np.zeros(T)
ans = 0
for a, b in data:
  ans = max(ans, dp[-1]+b)
  if a < T:
    newtable = dp[:T-a] + b
    dp[a:] = np.maximum(dp[a:], newtable)
print(int(ans))
### BUGGY CODE ###

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
X = str(input())
start_number = int(X,2)
start_mod = X.count("1")

# print(start_number,"debug")
for i in range(n):
  if X[i] == "1":
    now_number = start_number - pow(2,n-1-i)
    now_mod = start_mod - 1
      
  else:
    now_number = start_number + pow(2,n-1-i)
    now_mod = start_mod + 1

  ci = 0
  while now_number != 0:
    # print(now_number,now_mod)
    now_number %= now_mod
    now_mod = bin(now_number).count("1")
    ci += 1
  print(ci)

### FIXED CODE ###

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
X = str(input())
start_mod = X.count("1")
if start_mod == 1:
  for i in range(n):
    if X[i] == "1":
      key = i
else: key = -1

def bin_to_int(n,binstr,mod):
  retval = 0
  for i in range(n-1,-1,-1):
    retval += (pow(2,n-1-i,mod) if binstr[i] == "1" else 0)
    retval %= mod
  return retval

start_number_plus = bin_to_int(n,X,start_mod+1)
if key == -1:
  start_number_minus = bin_to_int(n,X,start_mod-1)
# print(start_number_plus,start_number_minus,"debug")

# print(key,"debug3")
for i in range(n):
  if i == key:print(0);continue
  if X[i] == "1":
    now_mod = start_mod - 1
    now_number = (start_number_minus - pow(2,n-1-i,now_mod))%now_mod
      
  else:
    now_mod = start_mod + 1
    now_number = (start_number_plus + pow(2,n-1-i,now_mod))%now_mod
  # print(i,now_number,now_mod,"debug")
  ci = 1
  while now_number != 0:
    # print(now_number,now_mod)
    now_mod = bin(now_number).count("1")
    now_number %= now_mod
    ci += 1
  print(ci)
### BUGGY CODE ###

import math
import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sa = np.zeros(n,dtype=int)
    ans = 0
    for i,ai in enumerate(a):
        sa[:i+1:] += ai
        ans += np.count_nonzero(sa[:i+1:]==0)
    print(ans)

    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    d = defaultdict(int)
    sa = 0
    for i in a:
        sa += i
        d[sa] += 1
    ans = 0
    for iv in d.values():
        ans += iv*(iv-1)//2
    print(ans+d[0])
    return

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math
import collections

def main():
    ansdic={}
    n = int(input())
    num_list = list(map(int, input().split()))  
    for i in range(len(num_list)):
        if i in ansdic:
          print(ansdic[i])
       	else:
          pop = num_list.pop(i)
          dic = collections.Counter(num_list)
          for k, j in dic.items():
              if j < 2:
                pass
              else:
                ansdic[k] = int(j * (j-1)/2)
          print(sum(ansdic.values()))
          ansdic = {}
          num_list.insert(i, pop)
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import math
    n = int(input())
    inlis = list(map(int, input().split()))
    indic = dict()
    total = 0

    for num in inlis:
        if num in indic:
            indic[num] += 1
        else:
            indic[num] = 1
    
    for k, v in indic.items():
        total += int(v * (v-1) / 2)
    
    for num in inlis:
        print(total - indic[num] + 1)





if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())
mozi.sort()
li = list()
for i in range(n):
    if not mozi[i] in li:
        li.append(mozi[i])
kazu = list()
for i in li:
    kazu.append(mozi.count(i))
m = [i for i ,x in enumerate(kazu) if x == max(kazu)]
for i in m:
    print(li[i],end=" ")

### FIXED CODE ###

import collections

n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())

c = collections.Counter(mozi)
m = max(c.values())
c = sorted(c.items())

for i in c:
    if (i[1] == m):
        print(i[0])
### BUGGY CODE ###

S = input()
Q = int(input())

for i in range(Q):
    Que = input().split()

    if Que[0] == '1':
        S = S[::-1]

    if Que[0] == '2':
        if Que[1] == '1':
            S = Que[2] + S
        
        if Que[1] == '2':
            S = S + Que[2]

print(S)


### FIXED CODE ###

S = input()
Q = int(input())

A=""
Z=""
AZFlag = 0
for i in range(Q):
    Que = input().split()

    if Que[0] == '1':
        if AZFlag == 0:
            AZFlag = 1
            continue

        if AZFlag == 1:
            AZFlag = 0
            continue

    if Que[0] == '2':
        if Que[1] == '1' and AZFlag == 0:
            A = Que[2]+A
            continue

        if Que[1] == '1' and AZFlag == 1:
            Z = Z+Que[2]
            continue
        
        if Que[1] == '2' and AZFlag == 0:
            Z = Z+Que[2]
            continue

        if Que[1] == '2' and AZFlag == 1:
            A = Que[2]+A
            continue


if AZFlag == 0:
    print(A+S+Z)
if AZFlag == 1:
    print(Z[::-1]+S[::-1]+A[::-1])
### BUGGY CODE ###

def main():
    s = int(input())
    x = int(s**0.5//1)
    if s <= 10**9:
        print(0,0,1,0,0,s)
        exit()
    for i,j in zip(range(x,0,-1),range(x,s+1)):
        if s%i ==0:
            x = i
            break
        elif s%j == 0:
            x = i
            break
    y = int(s/x)
    print(0,0,x,0,0,y)
if __name__ == '__main__':
    main()

### FIXED CODE ###

S=int(input())
if S<10**18:
    x1,y1,x2,y2,x3,y3=0,0,(S//10**9+1),10**9-S%10**9,1,10**9
else:
    x1,y1,x2,y2,x3,y3=(0,0,10**9,1,0,10**9)
print(x1,y1,x2,y2,x3,y3)
### BUGGY CODE ###

def main():
    N = int(input())
    A = [x for x in input().split()]
    l = [0] * N
    B = set(A)
    C = list(B)
    for i in C:
        l[int(i)-1] = A.count(i)
    for i in range(N):
        print(l[i])
        
main()

### FIXED CODE ###

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()