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

H, W = map(int, input().split())
sh, sw = map(int, input().split())
gh, gw = map(int, input().split())

sh += 1
sw += 1
gh += 1
gw += 1

S = [0]*(H+4)
S[0] = '*'*(W+4)
S[1] = '*'*(W+4)
S[-2] = '*'*(W+4)
S[-1] = '*'*(W+4)
for h in range(2,H+2):
  S[h] = '**' + input() + '**'

visited = [[float('inf')]*(W+4) for _ in range(H+4)]
dh1 = [0,1,0,-1]
dw1 = [1,0,-1,0]
dh2 = [2,2,2,2,2,1,1,1,1,0,0,-1,-1,-1,-1,-2,-2,-2,-2,-2]
dw2 = [-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2]

from collections import deque
d = deque()
visited[sh][sw] = 0
d.append(sh*(W+4)+sw)

while len(d)>0:
  a = d.popleft()
  h,w = divmod(a,W+4)
  cnt = visited[h][w]
  for i in range(4):
    h1 = h+dh1[i]
    w1 = w+dw1[i]
    if S[h1][w1]=='.':
      if visited[h1][w1]>cnt:
        visited[h1][w1]=cnt
        d.append((h1*(W+4)+w1))
  for i in range(20):
    h2 = h+dh2[i]
    w2 = w+dw2[i]
    if S[h2][w2]=='.':
      if visited[h2][w2]>cnt+1:
        visited[h2][w2]=cnt+1
        d.append((h2*(W+4)+w2))
ans = visited[gh][gw] if visited[gh][gw]<float('inf') else -1
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
sh, sw = map(int, input().split())
gh, gw = map(int, input().split())

sh += 1
sw += 1
gh += 1
gw += 1
s = sh*(W+4)+sw
g = gh*(W+4)+gw
S = [0]*(H+4)
S[0] = '*'*(W+4)
S[1] = '*'*(W+4)
S[-2] = '*'*(W+4)
S[-1] = '*'*(W+4)
for h in range(2,H+2):
  S[h] = '**' + input() + '**'

visited = [10**7]*((W+4)*(H+4))
dh1 = [0,1,0,-1]
dw1 = [1,0,-1,0]
dh2 = [2,2,2,2,2,1,1,1,1,0,0,-1,-1,-1,-1,-2,-2,-2,-2,-2]
dw2 = [-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2]

from collections import deque

d = deque()
visited[s] = 0
d.append(s)
ans = 10**8
while len(d)>0:
  a = d.popleft()
  h,w = divmod(a,W+4)
  cnt = visited[a]
  if ans<=cnt:
    continue
  for i in range(4):
    h1 = h+dh1[i]
    w1 = w+dw1[i]
    a1 = h1*(W+4)+w1
    if (h1,w1)==(gh,gw):
      ans = min(ans,cnt)
    if S[h1][w1]=='.':
      if visited[a1]>cnt:
        visited[a1]=cnt
        d.appendleft(a1)
  for i in range(20):
    h2 = h+dh2[i]
    w2 = w+dw2[i]
    a2 = h2*(W+4)+w2
    if (h2,w2)==(gh,gw):
      ans = min(ans,cnt+1)
    if S[h2][w2]=='.':
      if visited[a2]>cnt+1:
        visited[a2]=cnt+1
        d.append(a2)
if ans==10**8:
  ans = -1
print(ans)
### BUGGY CODE ###

N = int(input())

syurui = []
for i in range(N):
    S = input()
    if S in syurui: continue
    else: syurui.append(S)

print(len(syurui))


### FIXED CODE ###


N = int(input())

L = []
for i in range(N):
    L.append(input())

LL = sorted(L)

ans = 1
for i in range(N-1):
    if LL[i+1] != LL[i]: ans += 1

print(ans)
### BUGGY CODE ###

n = int(input())
lists = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= lists[i]
    if sorted(lists)[0] == 0:
        ans = 0
        break
    if ans > 10**18:
        ans = -1
        break
print(ans)

### FIXED CODE ###

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

N=int(input())
S = [input() for i in range(N)]
result=[]
name=[]

result=[S.count(S[i]) for i in range(N)]
m=max(result)

for i in range(N):
    if m==result[i]:
        name.append(S[i])
name_set=set(name)
name_list=sorted(list(name_set))

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

### FIXED CODE ###

from collections import Counter

N=int(input())
S = [input() for i in range(N)]
result=[]

counter = Counter(S)
m = max(counter.values())

for name in counter.keys():
    if m==counter[name]:
        result.append(name)

result_sort=sorted(result)

for i in range(len(result_sort)):
    print(result_sort[i])
### BUGGY CODE ###

S = input()
N = len(S)
K = int(input())
ans = set()
for c in "abcdefghijklmnopqrstuvwxyz":
    for i in range(N):
        if S[i] == c:
            for j in range(i + 1, N + 1):
                ans.add(S[i:j])
    if len(ans) >= K:
        break
print(sorted(list(ans))[K - 1])


### FIXED CODE ###

s = input()
K = int(input())
s_dic = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
for i, c in enumerate(s):
    s_dic[c].append(i)
substrings = set()
for indices in s_dic.values():
    for i in indices:
        for j in range(i + 1, i + K + 1):
            substrings.add(s[i:j])
print(sorted(list(substrings))[K - 1])
### BUGGY CODE ###

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

q = 0
if len(H) >= 2:
  for i in range(len(H)-1):
    if max(H[:i+1]) > H[i+1] + 1:
      q += 1
    
if q == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

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

q, c = 0, 0
if len(H) >= 2:
  i = 0
  while i < len(H) - 1 and q == 0:
    if c <= H[i]:
      c = H[i]
    if c > H[i+1] + 1:
      q += 1
    i += 1
    
if q == 0:
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline

h, w = map(int, input().split())
map = [input() for _ in range(h)]

f_inf = float('inf')
visited = [[f_inf] * w for _ in range(h)]
que = deque([])
for i in range(h):
    for j in range(w):
        if map[i][j] == "#":
            visited[i][j] = 0
            que.append((i, j))

ans = 0
while que:
    y, x = que.popleft()
    for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        next_y, next_x = y + i, x + j
        ans = visited[y][x]
        if -1 < next_y < h and -1 < next_x < w and map[next_y][next_x] == ".":
            if visited[next_y][next_x] > visited[y][x] + 1:
                visited[next_y][next_x] = visited[y][x] + 1
                que.append((next_y, next_x))

print(int(ans))


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

cnt = [[-1]*W for _ in range(H)]

que = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            que.append((h, w))
            cnt[h][w] = 0

ans = 0
while que:
    h, w = que.popleft()
    ans = cnt[h][w]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        next_h = h + dy
        next_w = w + dx
        if next_h < 0 or H <= next_h or next_w < 0 or W <= next_w:
            continue
        if cnt[next_h][next_w] == -1:
            cnt[next_h][next_w] = ans+1
            que.append((next_h, next_w))

print(int(ans))
### BUGGY CODE ###

S = str(input())

def solution(S):
    a = len(S)
    count = 0
    for j in range(4, a+1):
        for i in range(a-j+1):
            if int(S[i:i+j])%2019==0:
                count += 1
    print(count)
solution(S)

### FIXED CODE ###

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
### BUGGY CODE ###

import numpy as np
from bisect import *
n, m = map(int, input().split())
A, B, C = zip(*(map(int, input().split()) for _ in range(n)))
D, E, F = zip(*(map(int, input().split()) for _ in range(m)))
X = sorted(set(C + E + F))
Y = sorted(set(A + B + D))
H = len(Y)-1
W = len(X)-1
def TX(i):
    return bisect(X, i)-1
def TY(i):
    return bisect(Y, i)-1
U = np.ones((H+1, W))
for d, e, f in zip(D, E, F):
    d, e, f = TY(d), TX(e), TX(f)
    U[d, e:f] = False
L = np.ones((H, W+1))
for a ,b, c in zip(A, B, C):
    a, b, c = TY(a), TY(b), TX(c)
    L[a:b, c] = False
S = np.outer(np.diff(Y), np.diff(X)) 
i = bisect(Y, 0)-1
j = bisect(X, 0)-1
s = [(i,j)]
v = set()
r = 0
while s:
    i, j = s.pop()
    if (i,j) in v:
        continue
    v.add((i,j))
    if not (0<=i<H and 0<=j<W):
        print('INF')
        break
    r += S[i][j]
    if U[i][j]:
        s.append((i-1,j))
    if U[i+1][j]:
        s.append((i+1,j))
    if L[i][j]:
        s.append((i,j-1))
    if L[i][j+1]:
        s.append((i,j+1))
else:
    print(r)


### FIXED CODE ###

import numpy as np
from numba import njit
from bisect import *
n, m = map(int, input().split())
A, B, C = zip(*(map(int, input().split()) for _ in range(n)))
D, E, F = zip(*(map(int, input().split()) for _ in range(m)))
X = sorted(set(C))
Y = sorted(set(D))
H = len(Y)-1
W = len(X)-1
def TX(i):
    return bisect(X, i)-1
def TY(i):
    return bisect(Y, i)-1
U = np.ones((H+1, W))
for d, e, f in zip(D, E, F):
    #d, e, f = TY(d), TX(e), TX(f)
    d = TY(d)
    e = bisect_left(X, e)
    f = bisect_right(X, f)-1
    U[d, e:f] = False
L = np.ones((H, W+1))
for a ,b, c in zip(A, B, C):
    #a, b, c = TY(a), TY(b), TX(c)
    c = TX(c)
    a = bisect_left(Y, a)
    b = bisect_right(Y, b)-1
    L[a:b, c] = False
S = np.outer(np.diff(Y), np.diff(X))
@njit
def dfs(i, j):
    s = [(i,j)]
    v = np.zeros((H,W))
    r = 0
    while s:
        i, j = s.pop()
        if not (0<=i<H and 0<=j<W):
            return -1
        if v[i,j]:
            continue
        v[i,j] = True
        r += S[i,j]
        if U[i,j]:
            s.append((i-1,j))
        if U[i+1,j]:
            s.append((i+1,j))
        if L[i,j]:
            s.append((i,j-1))
        if L[i,j+1]:
            s.append((i,j+1))
    return r
r = dfs(TY(0), TX(0))
print('INF' if r<0 else r)
### BUGGY CODE ###

from collections import defaultdict as dd
primes = dd(int)
n,p = map(int, input().split())
gcd = 1
for i in range(2,p+1):
  while p%i == 0:
    p //= i
    primes[i] += 1
for fac in primes:
  gcd *= fac**(primes[fac]//n)
print(gcd)

### FIXED CODE ###

from collections import defaultdict as dd
primes = dd(int)
n,p = map(int, input().split())
gcd = 1
for i in range(2,int(p**.5)+1):
  while p%i == 0:
    p //= i
    primes[i] += 1
if p > 1:
  primes[p] += 1
for fac in primes:
  gcd *= fac**(primes[fac]//n)
print(gcd)
### BUGGY CODE ###

n=int(input())
a = [input() for i in range(n)]
b = sorted(list(set(a)))
d = {}
m = 0

for i in b:
    t = a.count(i)
    if m > 0 and t < m:
        continue

    d.setdefault(t,[])
    d[t].append(i)
    if t > m:
        m = t

for i in d[max(d.keys())]:
    print(i)

### FIXED CODE ###

from collections import defaultdict

n=int(input())

d=defaultdict(int)


for i in range(n):
    d[input()] +=1

m =max(d.values())

for i,j in sorted(d.items()):
    if j == m :print(i)
### BUGGY CODE ###

n = int(input())
s = input()

ans = 0

for i in range(1000):
    # 確認するpinの数字の組み合わせと桁の初期化
    # pin = f'{i:0>3}'
    pin = list(str(i).zfill(3))
    current_digit = 0

    for num in s:
        # 見つけると桁を右に一つずらす
        if num == pin[current_digit]:
            current_digit += 1
            # indexが3(桁が3→2→1→0)になったときはそのPINは作れる
            if current_digit == 3:
                ans += 1
                break

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

ans = 0

for i in range(1000):
    # 確認するpinの数字の組み合わせと桁の初期化
    current_digit = 0
    pin = f'{i:0>3}'
    # pin = list(str(i).zfill(3))
    k = pin[current_digit]

    for num in s:
        # 見つけると桁を右に一つずらす
        if num == k:
            current_digit += 1
            # indexが3(桁が3→2→1→0)になったときはそのPINは作れる
            if current_digit <= 2:
                k = pin[current_digit]

            elif current_digit == 3:
                ans += 1
                break

print(ans)
### BUGGY CODE ###

n = int(input())
p_list = list(map(int,input().split()))

count = 1
for i in range(1, len(p_list)):
  if len(p_list) >= 0 :
    if min(p_list[:i+1]) == p_list[i] :
      count += 1
      
print(count)

### FIXED CODE ###

n = int(input())
p_list = list(map(int,input().split()))

count = 1
min = min(p_list[:1]) 
for i in range(1, n):
  if min > p_list[i] :
    count += 1
    min = p_list[i] 

print(count)
### BUGGY CODE ###

ans=0
s=input()
if len(s)<4:
  print(0)
  exit()
N=len(s)
L=list()
for i in range(N):
  L.append(int(s[i:])%2019)
L.append(0)
print(len(L)-len(set(L)))

### FIXED CODE ###

ans=0
S=input()
a=len(S)
k=0
c=dict()
mod=2019
s=1
c[0]=1
for i in range(a):
  k+=(s*int(S[a-i-1]))
  k%=mod
  s*=10
  s%=mod
  if k in c:
    c[k]+=1
  else:
    c[k]=1
for i in c:
  ans+=c[i]*(c[i]-1)//2
print(ans)
### BUGGY CODE ###

h,w=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
s=[list(input()) for _ in range(h)]

Ch,Cw=Ch-1,Cw-1
Dh,Dw=Dh-1,Dw-1
todo=[[0,Ch,Cw]]
d=[[-1]*w for _ in range(h)]
d[Ch][Cw]=0
toho=[[0,1],[0,-1],[1,0],[-1,0]]
wiz=[[2,2],[2,1],[2,0],[2,-1],[2,-2],[1,2],[1,1],[1,-1],[1,-2],[0,2],[0,-2],[-1,2],[-1,1],[-1,-1],[-1,-2],[-2,2],[-2,1],[-2,0],[-2,-1],[-2,-2]]
while todo:
  cnt,nh,nw=todo.pop()
  if d[nh][nw]<cnt:continue
  for dh,dw in toho:
    if 0<=nh+dh<h and 0<=nw+dw<w and s[nh+dh][nw+dw]!='#':
      if d[nh+dh][nw+dw]==-1 or d[nh+dh][nw+dw]>cnt:
        d[nh+dh][nw+dw]=cnt
        todo.append([cnt,nh+dh,nw+dw])
  for dh,dw in wiz:
    if 0<=nh+dh<h and 0<=nw+dw<w and s[nh+dh][nw+dw]!='#':
      if d[nh+dh][nw+dw]==-1 or d[nh+dh][nw+dw]>cnt+1:
        d[nh+dh][nw+dw]=cnt+1
        todo.append([cnt+1,nh+dh,nw+dw])
print(d[Dh][Dw])


### FIXED CODE ###

h,w=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
s=[list(input()) for _ in range(h)]

Ch,Cw=Ch-1,Cw-1
Dh,Dw=Dh-1,Dw-1
todo=[[0,Ch,Cw]]
ntodo=[]
d=[[-1]*w for _ in range(h)]
d[Ch][Cw]=0
toho=[[0,1],[0,-1],[1,0],[-1,0]]
wiz=[[2,2],[2,1],[2,0],[2,-1],[2,-2],[1,2],[1,1],[1,-1],[1,-2],[0,2],[0,-2],[-1,2],[-1,1],[-1,-1],[-1,-2],[-2,2],[-2,1],[-2,0],[-2,-1],[-2,-2]]
while todo or ntodo:
  if not todo:
    todo=ntodo
    ntodo=[]
  cnt,nh,nw=todo.pop()
  if d[nh][nw]<cnt:continue
  for dh,dw in toho:
    if 0<=nh+dh<h and 0<=nw+dw<w and s[nh+dh][nw+dw]!='#':
      if d[nh+dh][nw+dw]==-1 or d[nh+dh][nw+dw]>cnt:
        d[nh+dh][nw+dw]=cnt
        todo.append([cnt,nh+dh,nw+dw])
  for dh,dw in wiz:
    if 0<=nh+dh<h and 0<=nw+dw<w and s[nh+dh][nw+dw]!='#':
      if d[nh+dh][nw+dw]==-1 or d[nh+dh][nw+dw]>cnt+1:
        d[nh+dh][nw+dw]=cnt+1
        ntodo.append([cnt+1,nh+dh,nw+dw])
print(d[Dh][Dw])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
n, q = map(int, input().split())
res = []
tree = []
level = []
childs = []
parent = []
for i in range(210000):
    res.append(0)
    tree.append([])
    level.append(-1)
    childs.append([])
    parent.append(-1)


for loop in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

def make_level(index, lev):
    l = 0
    level[index] = lev
    for next in tree[index]:
        # 逆走はしない
        if level[next] != -1:
            continue
        # 子供に親を設定
        parent[next] = index
        curparent = index
        add_parent(index, next)

        make_level(next, lev + 1)


def add_parent(index, childindex):
    if index != -1:
        #print("add {0}, {1}".format(index, childindex))
        childs[index].append((childindex))
        add_parent(parent[index], childindex)


make_level(1, 0)
#print(level[0:10])
#print(parent[0:10])
#print(childs[0:10])

for loop in range(q):
    p, x = map(int, input().split())
    res[p] += x
    for childindex in childs[p]:
        res[childindex] += x

res = list(map(str, res))
print(" ".join(res[1:n+1]))

### FIXED CODE ###

edge = []
n, q = map(int, input().split())
for _ in range(n+100):
    edge.append([])
for _ in range(n-1):
    a,b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)
res = [0] * (n+1)
cost = [0] * (n+1)
for _ in range(q):
    a,b = map(int, input().split())
    res[a] += b

import collections
q = collections.deque([[1, 0]])
used = [False] * (n+1)
while len(q) > 0:
    #print(q)
    curnode, cost = q.popleft()
    res[curnode] += cost
    used[curnode] = True
    for i in range(len(edge[curnode])):
        nnext = edge[curnode][i]
        if used[nnext] is True:
            continue
        else:
            q.append([nnext, res[curnode]])
res=res[1:]
print(" ".join(list(map(str, res))))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    
    L = [A.pop(0)]
    ma = L[0]
    for a in A:
        if ma >= a:
            ma = a
            L.append(ma)
            continue
        for i, l in enumerate(L):
            if l < a:
                L[i] = a
                if l == ma:
                    ma = L[-1]
                break
        else:
            L.append(a)
    return len(L)


def main():
    N = read_int()
    A = [read_int() for _ in range(N)]
    print(slv(N, A))

    # N = 10**5
    # A = [random.randint(1, 10**9) for _ in range(N//2)]
    # A.sort()
    # A.reverse()
    # A += [random.randint(1, 10**9) for _ in range(N//2)]
    # print(slv(N, A))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


# @mt
def slv(N, A):
    
    L = [-A.pop(0)]
    ma = L[0]
    for a in A:
        if ma <= -a:
            ma = -a
            L.append(ma)
            continue
        i = bisect.bisect_right(L, -a)
        L[i] = -a
        ma = L[-1]
    return len(L)



def main():
    N = read_int()
    A = [read_int() for _ in range(N)]
    print(slv(N, A))


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

from collections import defaultdict
import math

N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
for i in range(len(A)):
    d[A[i]] += 1

ans1 = 0
ans2 = 0
r = 2
calc_dict1 = {}
calc_dict2 = {}
for k, v in zip(d.keys(), d.values()):
    if v > 1:
        ans1 = math.factorial(v) // (math.factorial(v - r) * math.factorial(r))
    else:
        ans1 = 0
    if v > 2:
        ans2 = math.factorial(v - 1) // (math.factorial(v - 1 - r) * math.factorial(r))
    else:
        ans2 = 0
    calc_dict1[k] = ans1
    calc_dict2[k] = ans1 - ans2
total = sum(calc_dict1.values())
for i in range(N):
    print(total - calc_dict2[A[i]])

### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
for i in range(len(A)):
    d[A[i]] += 1
total = 0
for k,v in d.items():
    total += v*(v-1)//2
for a in A:
    print(total - (d[a]-1))
### BUGGY CODE ###

N=int(input())
S=[list(input()) for _ in range(N)]

ans=0
for k in range(N):
  ju=1
  for i in range(N):
    for j in range(N):
      if S[i][(k+j)%N]!=S[j][(k+i)%N]:
        ju=0
        
  if ju==1:
    ans+=1

print(N*ans)

### FIXED CODE ###

N=int(input())
S=[list(input()) for _ in range(N)]

ans=0
for k in range(N):
  ju=1
  for i in range(N):
    for j in range(N):
      if S[i][(k+j)%N]!=S[j][(k+i)%N]:
        ju=0
        
  if ju==1:
    ans+=1

print(N*ans)
### BUGGY CODE ###

N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]

X = [set([i]) for i in range(1,N+1)]

C = [0]
for a, b in L[::-1]:
    xa = [x for x in X if a in x][0]
    xb = [x for x in X if b in x][0]
    if(len(xa ^ xb)!=0):
        C.append(C[-1]+len(xa)*len(xb))
        X.remove(xa)
        X.remove(xb)
        X.append(xa | xb)
    else:
        C.append(C[-1])

for c in C[:-1][::-1]:
    print(N*(N-1)//2-c)

### FIXED CODE ###

N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]

X = [set([i]) for i in range(1,N+1)]

par = list(range(N+1))
rank = [0] * (N+1)
size = [1] * (N+1)

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
        size[y] += size[x]
    else:
        par[y] = x
        size[x] += size[y]
        if rank[x] == rank[y]:
            rank[x] += 1
    return

C = [0]
for a, b in L[::-1]:
    xa = find(a)
    xb = find(b)
    if xa == xb:
        C.append(C[-1])
    else:
        C.append(C[-1] + size[xa] * size[xb])
        unite(xa, xb)

for c in C[:-1][::-1]:
    print(N*(N-1)//2-c)
### BUGGY CODE ###

import time
import copy

d,g = map(int,input().split())
P = []
C = []
for i in range(d):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

# start = time.time()

m = 10**9
maxp = d-1

def flag(point,P,now):
    if point+100*(now+1)*P >= g:
        return 1
    else:
        return 0

def score(point = 0, n = 0, now=0, done=[]):
    global m
    donecp = copy.deepcopy(done)
    if point >= g:
        if m > n: m = n
    else:
        if flag(point,P[now],now):
            for i in range(1,P[now]+1):
                point += 100*(now+1)
                n += 1
                if point >= g:
                    if m > n:
                        m = n
                        break
        donecp.append(now)
        for i in range(d):
            if not i in donecp:
                score(point+P[now]*100*(now+1) + C[now], n + P[now], i, donecp)

for i in range(d):
    done = []
    score(0,0,i,done)

# elapsed_time = time.time() - start

print(m)

### FIXED CODE ###

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)
### BUGGY CODE ###

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

for i in range(1, N+1):
  print(A.count(i))

### FIXED CODE ###

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

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

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